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., 51 Franklin Street, Fifth Floor, 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;
50 /* Does not require locking: meant to be called after the drawing
53 classpath_jawt_get_default_display (JNIEnv* env, jobject canvas)
63 /* retrieve peer object */
64 class_id = (*env)->GetObjectClass (env, canvas);
66 method_id = (*env)->GetMethodID (env, class_id,
68 "()Ljava/awt/peer/ComponentPeer;");
70 peer = (*env)->CallObjectMethod (env, canvas, method_id);
72 ptr = NSA_GET_PTR (env, peer);
74 widget = GTK_WIDGET (ptr);
76 if (GTK_WIDGET_REALIZED (widget))
78 display = gtk_widget_get_display (widget);
80 xdisplay = GDK_DISPLAY_XDISPLAY (display);
88 /* Does not require locking: meant to be called after the drawing
91 classpath_jawt_get_visualID (JNIEnv* env, jobject canvas)
100 class_id = (*env)->GetObjectClass (env, canvas);
102 method_id = (*env)->GetMethodID (env, class_id,
104 "()Ljava/awt/peer/ComponentPeer;");
106 peer = (*env)->CallObjectMethod (env, canvas, method_id);
108 ptr = NSA_GET_PTR (env, peer);
110 widget = GTK_WIDGET (ptr);
112 if (GTK_WIDGET_REALIZED (widget))
114 visual = gdk_x11_visual_get_xvisual (gtk_widget_get_visual (widget));
115 g_assert (visual != NULL);
117 return visual->visualid;
120 return (VisualID) NULL;
123 /* Does not require locking: meant to be called after the drawing
124 surface is locked. */
126 classpath_jawt_get_drawable (JNIEnv* env, jobject canvas)
135 class_id = (*env)->GetObjectClass (env, canvas);
137 method_id = (*env)->GetMethodID (env, class_id,
139 "()Ljava/awt/peer/ComponentPeer;");
141 peer = (*env)->CallObjectMethod (env, canvas, method_id);
143 ptr = NSA_GET_PTR (env, peer);
145 widget = GTK_WIDGET (ptr);
147 if (GTK_WIDGET_REALIZED (widget))
149 drawable = GDK_DRAWABLE_XID (widget->window);
154 return (Drawable) NULL;
158 classpath_jawt_lock ()
160 gdk_threads_enter ();
165 classpath_jawt_unlock ()
167 gdk_threads_leave ();