Hi,

Elias Naur wrote:
Hi,

This trivial patch (most of classpath_jawt_get_depth() was lifted from classpath_jawt_get_xvisual()) makes sure the depth field of the JAWT_X11DrawingSurfaceInfo structure returned from JAWT is initialized to the depth of the Canvas' visual. Previously, the depth value was left uninitialized which confused LWJGL (http://lwjgl.org).

Elias's paperwork went through but he doesn't have commit access yet. I committed this patch on his behalf.

Tom

2006-10-26  Christian Elias Naur  <[EMAIL PROTECTED]>

        * native/jni/gtk-peer/gtk_jawt.c (classpath_jawt_get_depth): New
        function.
        * native/jni/classpath/classpath_jawt.h: Likewise.
        * native/jawt/jawt.c (_Jv_GetDrawingSurfaceInfo): Added
        initializer for surface_info_x11->depth.
--- native/jawt/jawt.c	13 Sep 2005 18:58:09 -0000	1.3
+++ native/jawt/jawt.c	26 Oct 2006 21:47:08 -0000
@@ -116,6 +116,8 @@
                                                             surface->target);
   surface_info_x11->visualID = classpath_jawt_get_visualID (surface->env,
                                                             surface->target);
+  surface_info_x11->depth = classpath_jawt_get_depth (surface->env,
+                                                            surface->target);
 
   /* FIXME: also include bounding rectangle of drawing surface */
   /* FIXME: also include current clipping region */
--- native/jni/classpath/classpath_jawt.h	20 Aug 2005 22:46:54 -0000	1.4
+++ native/jni/classpath/classpath_jawt.h	26 Oct 2006 21:47:08 -0000
@@ -54,6 +54,7 @@
 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);
+int      classpath_jawt_get_depth (JNIEnv* env, jobject canvas);
 jint     classpath_jawt_lock (void);
 void     classpath_jawt_unlock (void);
 
--- native/jni/gtk-peer/gtk_jawt.c	1 Sep 2005 16:34:39 -0000	1.4
+++ native/jni/gtk-peer/gtk_jawt.c	26 Oct 2006 21:47:08 -0000
@@ -122,6 +122,41 @@
 
 /* Does not require locking: meant to be called after the drawing
    surface is locked. */
+int
+classpath_jawt_get_depth (JNIEnv* env, jobject canvas)
+{
+  GtkWidget *widget;
+  GdkVisual *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);
+
+  widget = GTK_WIDGET (ptr);
+
+  if (GTK_WIDGET_REALIZED (widget))
+    {
+      visual = gtk_widget_get_visual (widget);
+      g_assert (visual != NULL);
+
+      return visual->depth;
+    }
+  else
+    return (VisualID) NULL;
+}
+
+/* Does not require locking: meant to be called after the drawing
+   surface is locked. */
 Drawable
 classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
 {

Reply via email to