1 /* 2 * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #ifdef HEADLESS 27 #error This file should not be included in headless library 28 #endif 29 30 #include <jni.h> 31 #include <X11/Xlib.h> 32 #include <X11/Xutil.h> 33 #include <awt.h> 34 #include <awt_p.h> 35 36 /* 37 * Fix 4221246: Provide utility function for Netscape to use to 38 * get AWT display, depth, colormap, and number of colors. 39 * 40 */ 41 42 Display *getAwtDisplay(void) 43 { 44 return awt_display; 45 } 46 47 void getExtAwtData(Display *display, 48 int32_t screen, 49 int32_t *awt_depth, 50 Colormap *awt_cmap, 51 Visual **awt_visual, 52 int32_t *awt_num_colors, 53 void *pReserved) 54 { 55 AwtGraphicsConfigDataPtr defaultConfig = NULL; 56 57 #ifdef DEBUG 58 if (pReserved != NULL) { 59 jio_fprintf(stderr, 60 "getExtAwtData: warning: reserved pointer is not null\n"); 61 } 62 #endif 63 64 if (screen >= 0) { 65 defaultConfig = getDefaultConfig(screen); 66 } 67 68 if (defaultConfig) { 69 if (awt_depth != NULL) { 70 *awt_depth = defaultConfig->awt_depth; 71 } 72 73 if (awt_cmap != NULL) { 74 *awt_cmap = defaultConfig->awt_cmap; 75 } 76 77 if (awt_visual != NULL) { 78 *awt_visual = defaultConfig->awt_visInfo.visual; 79 } 80 81 if (awt_num_colors != NULL) { 82 *awt_num_colors = defaultConfig->awt_num_colors; 83 } 84 } 85 } 86 87 /* 88 * getAwtData provided for compatibility with Solaris 1.2 Java Plug-in 89 * 90 */ 91 void getAwtData(int32_t *awt_depth, 92 Colormap *awt_cmap, 93 Visual **awt_visual, 94 int32_t *awt_num_colors, 95 void *pReserved) 96 { 97 Display *display = getAwtDisplay(); 98 99 getExtAwtData(display, 100 DefaultScreen(display), 101 awt_depth, 102 awt_cmap, 103 awt_visual, 104 awt_num_colors, 105 pReserved); 106 } 107 108 /* 109 * Fix 4221246: Provide utility funtion for Netscape to get 110 * function pointers to AWT lock functions. 111 * 112 */ 113 114 static void awt_lock_wrapper(JNIEnv *env) { 115 AWT_LOCK(); 116 } 117 118 static void awt_unlock_wrapper(JNIEnv *env) { 119 AWT_UNLOCK(); 120 } 121 122 static void awt_noflush_unlock_wrapper(JNIEnv *env) { 123 AWT_NOFLUSH_UNLOCK(); 124 } 125 126 void getAwtLockFunctions(void (**AwtLock)(JNIEnv *), 127 void (**AwtUnlock)(JNIEnv *), 128 void (**AwtNoFlushUnlock)(JNIEnv *), 129 void *pReserved) 130 { 131 #ifdef DEBUG 132 if (pReserved != NULL) { 133 jio_fprintf(stderr, 134 "getAwtLockFunctions: warning: reserved pointer is not null\n"); 135 } 136 #endif 137 138 if (AwtLock != NULL) { 139 *AwtLock = awt_lock_wrapper; 140 } 141 142 if (AwtUnlock != NULL) { 143 *AwtUnlock = awt_unlock_wrapper; 144 } 145 146 if (AwtNoFlushUnlock != NULL) { 147 *AwtNoFlushUnlock = awt_noflush_unlock_wrapper; 148 } 149 }