1 /* gtk_jawt.c -- GTK implementation of classpath_jawt.h
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
42 #include "classpath_jawt.h"
45 classpath_jawt_get_awt_version ()
47 return CLASSPATH_JAWT_VERSION;
51 classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
61 /* retrieve peer object */
62 class_id = (*env)->GetObjectClass (env, canvas);
64 method_id = (*env)->GetMethodID (env, class_id,
66 "()Ljava/awt/peer/ComponentPeer;");
68 peer = (*env)->CallObjectMethod (env, canvas, method_id);
70 ptr = NSA_GET_PTR (env, peer);
74 widget = GTK_WIDGET (ptr);
76 /* widget should be realized before Canvas.paint is called. */
77 g_assert (GTK_WIDGET_REALIZED (widget));
79 display = gtk_widget_get_display (widget);
81 xdisplay = GDK_DISPLAY_XDISPLAY (display);
89 classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
98 class_id = (*env)->GetObjectClass (env, canvas);
100 method_id = (*env)->GetMethodID (env, class_id,
102 "()Ljava/awt/peer/ComponentPeer;");
104 peer = (*env)->CallObjectMethod (env, canvas, method_id);
106 ptr = NSA_GET_PTR (env, peer);
108 gdk_threads_enter ();
110 widget = GTK_WIDGET (ptr);
112 g_assert (GTK_WIDGET_REALIZED (widget));
114 visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
115 g_assert (visual != NULL);
117 gdk_threads_leave ();
119 return visual->visualid;
123 classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
132 class_id = (*env)->GetObjectClass (env, canvas);
134 method_id = (*env)->GetMethodID (env, class_id,
136 "()Ljava/awt/peer/ComponentPeer;");
138 peer = (*env)->CallObjectMethod (env, canvas, method_id);
140 ptr = NSA_GET_PTR (env, peer);
142 gdk_threads_enter ();
144 widget = GTK_WIDGET (ptr);
146 g_assert (GTK_WIDGET_REALIZED (widget));
148 drawable = GDK_DRAWABLE_XID (widget->window);
150 gdk_threads_leave ();
156 classpath_jawt_object_lock (jobject lock)
158 JNIEnv *env = gdk_env();
159 (*env)->MonitorEnter (env, lock);
164 classpath_jawt_object_unlock (jobject lock)
166 JNIEnv *env = gdk_env();
167 (*env)->MonitorExit (env, lock);
171 classpath_jawt_lock ()
173 gdk_threads_enter ();
178 classpath_jawt_unlock ()
180 gdk_threads_leave ();
184 classpath_jawt_create_lock ()
186 JNIEnv *env = gdk_env ();
187 jobject lock = (*env)->NewStringUTF (env, "jawt-lock");
188 NSA_SET_GLOBAL_REF (env, lock);
193 classpath_jawt_destroy_lock (jobject lock)
195 JNIEnv *env = gdk_env ();
196 NSA_DEL_GLOBAL_REF (env, lock);