This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gui][patch] AWT Native Interface implementation


On Sun, 2005-02-13 at 11:03 -0800, Anthony Green wrote:
> On Fri, 2005-02-11 at 23:00 -0500, Thomas Fitzsimmons wrote:
> > I'll be testing other packages in the weeks to come, like Eclipse,
> > OpenOffice.org and the JOGL bindings.
> 
> I tried this with jogl and came up with the attached patch.
> The magic number values came from the public docs for a product called
> jniwrapper, here:
> http://www.jniwrapper.com/docs/javadoc_v1/constant-values.html
> 
> It's quite likely that the Lock and Unlock implementations are
> completely bogus.  I just wanted to get it to build and show something
> on the screen.  Hopefully it's not too far off from the right thing.
> 
> AG
> 
> 

I committed the original patch and a slightly modified version of your
patch (attached) to java-gui-20050128-branch.

Thanks,
Tom

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.3296.2.12
diff -u -r1.3296.2.12 ChangeLog
--- ChangeLog	13 Feb 2005 21:02:38 -0000	1.3296.2.12
+++ ChangeLog	13 Feb 2005 21:28:34 -0000
@@ -1,3 +1,17 @@
+2005-02-13  Anthony Green  <green@redhat.com>
+
+	* jni/gtk-peer/gtk_jawt.c (classpath_jawt_get_drawable,
+	classpath_jawt_lock, classpath_jawt_unlock): New functions.
+	* jawt.c (_Jv_JAWT_Lock, _Jv_JAWT_Unlock): New functions.
+	(_Jv_GetDrawingSurface): Set visualID.
+	(_Jv_FreeDrawingSurfaceInfo): Clear visualID.
+	(JAWT_GetAWT): Set Lock and Unlock.
+	* include/jawt_md.h (struct _JAWT_X11DrawingSurfaceInfo): Add visualID.
+	* include/jawt.h (JAWT_VERSION_1_4, JAWT_LOCK_ERROR,
+	JAWT_LOCK_CLIP_CHANGED, JAWT_LOCK_BOUNDS_CHANGED,
+	JAWT_LOCK_SURFACE_CHANGED): New macros.
+	(struct _JAWT): Add Lock and Unlock.
+
 2005-02-11  Thomas Fitzsimmons  <fitzsim@redhat.com>
 
 	* jawt.c: New file.
Index: jawt.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Attic/jawt.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 jawt.c
--- jawt.c	13 Feb 2005 21:02:49 -0000	1.1.2.1
+++ jawt.c	13 Feb 2005 21:28:34 -0000
@@ -41,15 +41,22 @@
 #include <jawt_md.h>
 #include "classpath_jawt.h"
 
+/* JAWT_DrawingSurface function declarations */
+
 static jint (JNICALL _Jv_Lock) (JAWT_DrawingSurface* surface);
 static void (JNICALL _Jv_Unlock) (JAWT_DrawingSurface* surface);
 static JAWT_DrawingSurfaceInfo* (JNICALL _Jv_GetDrawingSurfaceInfo)
      (JAWT_DrawingSurface* surface);
 static void (JNICALL _Jv_FreeDrawingSurfaceInfo)
      (JAWT_DrawingSurfaceInfo* surface_info);
+
+/* JAWT function declarations */
+
 static JAWT_DrawingSurface* (JNICALL _Jv_GetDrawingSurface) (JNIEnv* env,
 							     jobject canvas);
 static void (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface);
+static void (JNICALL _Jv_JAWT_Lock) (JNIEnv*);
+static void (JNICALL _Jv_JAWT_Unlock) (JNIEnv*);
 
 JNIEXPORT jboolean JNICALL
 JAWT_GetAWT (JNIEnv* env, JAWT* awt)
@@ -63,6 +70,8 @@
 
   awt->GetDrawingSurface = _Jv_GetDrawingSurface;
   awt->FreeDrawingSurface = _Jv_FreeDrawingSurface;
+  awt->Lock = _Jv_JAWT_Lock;
+  awt->Unlock = _Jv_JAWT_Unlock;
 
   return JNI_TRUE;
 }
@@ -103,6 +112,7 @@
 
   surface_info_x11->display = NULL;
   surface_info_x11->drawable = 0;
+  surface_info_x11->visualID = 0;
 
   free (surface_info);
   surface_info = NULL;
@@ -142,6 +152,7 @@
 
   surface_info_x11->display = classpath_jawt_get_default_display (env, canvas);
   surface_info_x11->drawable = classpath_jawt_get_drawable (env, canvas);
+  surface_info_x11->visualID = classpath_jawt_get_visualID (env, canvas);
 
   /* FIXME: also include bounding rectangle of drawing surface */
   /* FIXME: also include current clipping region */
@@ -154,3 +165,15 @@
 {
   free (surface);
 }
+
+static void
+(JNICALL _Jv_JAWT_Lock) (JNIEnv* env)
+{
+  classpath_jawt_lock ();
+}
+
+static void
+(JNICALL _Jv_JAWT_Unlock) (JNIEnv* env)
+{
+  classpath_jawt_unlock ();
+}
Index: include/jawt.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/Attic/jawt.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 jawt.h
--- include/jawt.h	13 Feb 2005 21:02:50 -0000	1.1.2.1
+++ include/jawt.h	13 Feb 2005 21:28:34 -0000
@@ -50,8 +50,12 @@
 #endif
 
 #define JAWT_VERSION_1_3 0x10003
+#define JAWT_VERSION_1_4 0x10004
 
 #define JAWT_LOCK_ERROR 0x1
+#define JAWT_LOCK_CLIP_CHANGED 0x2
+#define JAWT_LOCK_BOUNDS_CHANGED 0x4
+#define JAWT_LOCK_SURFACE_CHANGED 0x8
 
 struct _JAWT_DrawingSurfaceInfo
 {
@@ -74,9 +78,13 @@
 
 struct _JAWT
 {
-  jint version;
+  void (JNICALL *Lock) (JNIEnv*);
+  void (JNICALL *Unlock) (JNIEnv*);
+
   struct _JAWT_DrawingSurface* (JNICALL* GetDrawingSurface) (JNIEnv*, jobject);
   void (JNICALL* FreeDrawingSurface) (struct _JAWT_DrawingSurface*);
+
+  jint version;
 };
 
 typedef struct _JAWT_DrawingSurfaceInfo JAWT_DrawingSurfaceInfo;
Index: include/jawt_md.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/Attic/jawt_md.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 jawt_md.h
--- include/jawt_md.h	13 Feb 2005 21:02:50 -0000	1.1.2.1
+++ include/jawt_md.h	13 Feb 2005 21:28:34 -0000
@@ -52,6 +52,7 @@
 {
   Display* display;
   Drawable drawable;
+  VisualID visualID;
 };
 
 typedef struct _JAWT_X11DrawingSurfaceInfo JAWT_X11DrawingSurfaceInfo;
Index: jni/classpath/classpath_jawt.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/classpath/Attic/classpath_jawt.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 classpath_jawt.h
--- jni/classpath/classpath_jawt.h	13 Feb 2005 21:02:50 -0000	1.1.2.1
+++ jni/classpath/classpath_jawt.h	13 Feb 2005 21:28:36 -0000
@@ -53,6 +53,7 @@
 jint     classpath_jawt_get_awt_version ();
 Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas);
 Drawable classpath_jawt_get_drawable (JNIEnv* env, jobject canvas);
+VisualID classpath_jawt_get_visualID (JNIEnv* env, jobject canvas);
 jint     classpath_jawt_lock ();
 void     classpath_jawt_unlock ();
 
Index: jni/gtk-peer/gtk_jawt.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/Attic/gtk_jawt.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 gtk_jawt.c
--- jni/gtk-peer/gtk_jawt.c	13 Feb 2005 21:02:51 -0000	1.1.2.1
+++ jni/gtk-peer/gtk_jawt.c	13 Feb 2005 21:28:36 -0000
@@ -85,6 +85,40 @@
   return xdisplay;
 }
 
+VisualID
+classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
+{
+  GtkWidget *widget;
+  Visual *visual;
+  void *ptr;
+  jobject peer;
+  jclass class_id;
+  jmethodID method_id;
+
+  class_id = (*env)->GetObjectClass (env, canvas);
+
+  method_id = (*env)->GetMethodID (env, class_id,
+				   "getPeer",
+				   "()Ljava/awt/peer/ComponentPeer;");
+
+  peer = (*env)->CallObjectMethod (env, canvas, method_id);
+
+  ptr = NSA_GET_PTR (env, peer);
+
+  gdk_threads_enter ();
+
+  widget = GTK_WIDGET (ptr);
+
+  g_assert (GTK_WIDGET_REALIZED (widget));
+
+  visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
+  g_assert (visual != NULL);
+
+  gdk_threads_leave ();
+
+  return visual->visualid;
+}
+
 Drawable
 classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
 {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]