1*34dd1e25SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*34dd1e25SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*34dd1e25SAndrew Rist * distributed with this work for additional information
6*34dd1e25SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*34dd1e25SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*34dd1e25SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*34dd1e25SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist * KIND, either express or implied. See the License for the
17*34dd1e25SAndrew Rist * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*34dd1e25SAndrew Rist *************************************************************/
21*34dd1e25SAndrew Rist
22*34dd1e25SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include <X11/Xlib.h>
25cdf0e10cSrcweir #include <X11/Xutil.h>
26cdf0e10cSrcweir #include <X11/Intrinsic.h>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include "jawt.h"
29cdf0e10cSrcweir #include "jawt_md.h"
30cdf0e10cSrcweir #include "nativeview.h"
31cdf0e10cSrcweir
32cdf0e10cSrcweir #define MY_ASSERT(X,S) if (!X) { fprintf(stderr,S); return 0L;}
33cdf0e10cSrcweir
34cdf0e10cSrcweir #define SYSTEM_WIN32 1
35cdf0e10cSrcweir #define SYSTEM_WIN16 2
36cdf0e10cSrcweir #define SYSTEM_JAVA 3
37cdf0e10cSrcweir #define SYSTEM_OS2 4
38cdf0e10cSrcweir #define SYSTEM_MAC 5
39cdf0e10cSrcweir #define SYSTEM_XWINDOW 6
40cdf0e10cSrcweir
41cdf0e10cSrcweir /*****************************************************************************/
42cdf0e10cSrcweir /*
43cdf0e10cSrcweir * Class: NativeView
44cdf0e10cSrcweir * Method: getNativeWindowSystemType
45cdf0e10cSrcweir * Signature: ()I
46cdf0e10cSrcweir */
Java_NativeView_getNativeWindowSystemType(JNIEnv * env,jobject obj_this)47cdf0e10cSrcweir JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType
48cdf0e10cSrcweir (JNIEnv * env, jobject obj_this)
49cdf0e10cSrcweir {
50cdf0e10cSrcweir return (SYSTEM_XWINDOW);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir /*****************************************************************************/
54cdf0e10cSrcweir /*
55cdf0e10cSrcweir * Class: NativeView
56cdf0e10cSrcweir * Method: getNativeWindow
57cdf0e10cSrcweir * Signature: ()J
58cdf0e10cSrcweir */
Java_NativeView_getNativeWindow(JNIEnv * env,jobject obj_this)59cdf0e10cSrcweir JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow
60cdf0e10cSrcweir (JNIEnv * env, jobject obj_this)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir jboolean result ;
63cdf0e10cSrcweir jint lock ;
64cdf0e10cSrcweir JAWT awt ;
65cdf0e10cSrcweir JAWT_DrawingSurface* ds ;
66cdf0e10cSrcweir JAWT_DrawingSurfaceInfo* dsi ;
67cdf0e10cSrcweir JAWT_X11DrawingSurfaceInfo* dsi_x11 ;
68cdf0e10cSrcweir Drawable drawable;
69cdf0e10cSrcweir Display* display ;
70cdf0e10cSrcweir
71cdf0e10cSrcweir /* Get the AWT */
72cdf0e10cSrcweir awt.version = JAWT_VERSION_1_3;
73cdf0e10cSrcweir result = JAWT_GetAWT(env, &awt);
74cdf0e10cSrcweir MY_ASSERT(result != JNI_FALSE,"wrong jawt version");
75cdf0e10cSrcweir
76cdf0e10cSrcweir /* Get the drawing surface */
77cdf0e10cSrcweir if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
78cdf0e10cSrcweir return 0L;
79cdf0e10cSrcweir
80cdf0e10cSrcweir /* Lock the drawing surface */
81cdf0e10cSrcweir lock = ds->Lock(ds);
82cdf0e10cSrcweir MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
83cdf0e10cSrcweir
84cdf0e10cSrcweir /* Get the drawing surface info */
85cdf0e10cSrcweir dsi = ds->GetDrawingSurfaceInfo(ds);
86cdf0e10cSrcweir
87cdf0e10cSrcweir /* Get the platform-specific drawing info */
88cdf0e10cSrcweir dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
89cdf0e10cSrcweir drawable = dsi_x11->drawable;
90cdf0e10cSrcweir display = dsi_x11->display;
91cdf0e10cSrcweir
92cdf0e10cSrcweir /* Free the drawing surface info */
93cdf0e10cSrcweir ds->FreeDrawingSurfaceInfo(dsi);
94cdf0e10cSrcweir /* Unlock the drawing surface */
95cdf0e10cSrcweir ds->Unlock(ds);
96cdf0e10cSrcweir /* Free the drawing surface */
97cdf0e10cSrcweir awt.FreeDrawingSurface(ds);
98cdf0e10cSrcweir
99cdf0e10cSrcweir return ((jlong)drawable);
100cdf0e10cSrcweir }
101