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