Commit 011ad058 by Anthony Green Committed by Thomas Fitzsimmons

gtk_jawt.c (classpath_jawt_get_drawable, [...]): New functions.

2005-02-15  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.

From-SVN: r95943
parent 3f724eb8
...@@ -50,8 +50,12 @@ extern "C" ...@@ -50,8 +50,12 @@ extern "C"
#endif #endif
#define JAWT_VERSION_1_3 0x10003 #define JAWT_VERSION_1_3 0x10003
#define JAWT_VERSION_1_4 0x10004
#define JAWT_LOCK_ERROR 0x1 #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 struct _JAWT_DrawingSurfaceInfo
{ {
...@@ -77,6 +81,8 @@ struct _JAWT ...@@ -77,6 +81,8 @@ struct _JAWT
jint version; jint version;
struct _JAWT_DrawingSurface* (JNICALL* GetDrawingSurface) (JNIEnv*, jobject); struct _JAWT_DrawingSurface* (JNICALL* GetDrawingSurface) (JNIEnv*, jobject);
void (JNICALL* FreeDrawingSurface) (struct _JAWT_DrawingSurface*); void (JNICALL* FreeDrawingSurface) (struct _JAWT_DrawingSurface*);
void (JNICALL *Lock) (JNIEnv*);
void (JNICALL *Unlock) (JNIEnv*);
}; };
typedef struct _JAWT_DrawingSurfaceInfo JAWT_DrawingSurfaceInfo; typedef struct _JAWT_DrawingSurfaceInfo JAWT_DrawingSurfaceInfo;
......
...@@ -52,6 +52,7 @@ struct _JAWT_X11DrawingSurfaceInfo ...@@ -52,6 +52,7 @@ struct _JAWT_X11DrawingSurfaceInfo
{ {
Display* display; Display* display;
Drawable drawable; Drawable drawable;
VisualID visualID;
}; };
typedef struct _JAWT_X11DrawingSurfaceInfo JAWT_X11DrawingSurfaceInfo; typedef struct _JAWT_X11DrawingSurfaceInfo JAWT_X11DrawingSurfaceInfo;
......
...@@ -50,6 +50,8 @@ static void (JNICALL _Jv_FreeDrawingSurfaceInfo) ...@@ -50,6 +50,8 @@ static void (JNICALL _Jv_FreeDrawingSurfaceInfo)
static JAWT_DrawingSurface* (JNICALL _Jv_GetDrawingSurface) (JNIEnv* env, static JAWT_DrawingSurface* (JNICALL _Jv_GetDrawingSurface) (JNIEnv* env,
jobject canvas); jobject canvas);
static void (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface); static void (JNICALL _Jv_FreeDrawingSurface) (JAWT_DrawingSurface* surface);
static void (JNICALL _Jv_AWTLock) (JNIEnv*);
static void (JNICALL _Jv_AWTUnlock) (JNIEnv*);
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
JAWT_GetAWT (JNIEnv* env, JAWT* awt) JAWT_GetAWT (JNIEnv* env, JAWT* awt)
...@@ -63,6 +65,8 @@ JAWT_GetAWT (JNIEnv* env, JAWT* awt) ...@@ -63,6 +65,8 @@ JAWT_GetAWT (JNIEnv* env, JAWT* awt)
awt->GetDrawingSurface = _Jv_GetDrawingSurface; awt->GetDrawingSurface = _Jv_GetDrawingSurface;
awt->FreeDrawingSurface = _Jv_FreeDrawingSurface; awt->FreeDrawingSurface = _Jv_FreeDrawingSurface;
awt->Lock = _Jv_AWTLock;
awt->Unlock = _Jv_AWTUnlock;
return JNI_TRUE; return JNI_TRUE;
} }
...@@ -103,6 +107,7 @@ static void ...@@ -103,6 +107,7 @@ static void
surface_info_x11->display = NULL; surface_info_x11->display = NULL;
surface_info_x11->drawable = 0; surface_info_x11->drawable = 0;
surface_info_x11->visualID = 0;
free (surface_info); free (surface_info);
surface_info = NULL; surface_info = NULL;
...@@ -142,6 +147,7 @@ static JAWT_DrawingSurface* ...@@ -142,6 +147,7 @@ static JAWT_DrawingSurface*
surface_info_x11->display = classpath_jawt_get_default_display (env, canvas); surface_info_x11->display = classpath_jawt_get_default_display (env, canvas);
surface_info_x11->drawable = classpath_jawt_get_drawable (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 bounding rectangle of drawing surface */
/* FIXME: also include current clipping region */ /* FIXME: also include current clipping region */
...@@ -154,3 +160,16 @@ static void ...@@ -154,3 +160,16 @@ static void
{ {
free (surface); free (surface);
} }
static void
(JNICALL _Jv_AWTLock) (JNIEnv* env)
{
classpath_jawt_lock ();
}
static void
(JNICALL _Jv_AWTUnlock) (JNIEnv* env)
{
classpath_jawt_unlock ();
}
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
jint classpath_jawt_get_awt_version (); jint classpath_jawt_get_awt_version ();
Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas); Display* classpath_jawt_get_default_display (JNIEnv* env, jobject canvas);
Drawable classpath_jawt_get_drawable (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 (); jint classpath_jawt_lock ();
void classpath_jawt_unlock (); void classpath_jawt_unlock ();
......
...@@ -85,6 +85,40 @@ classpath_jawt_get_default_display (JNIEnv* env, jobject canvas) ...@@ -85,6 +85,40 @@ classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
return xdisplay; 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 Drawable
classpath_jawt_get_drawable (JNIEnv* env, jobject canvas) classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment