55 import sun.java2d.xr.XRSurfaceData;
56
57 /**
58 * This is an implementation of a GraphicsEnvironment object for the
59 * default local GraphicsEnvironment used by the Java Runtime Environment
60 * for X11 environments.
61 *
62 * @see GraphicsDevice
63 * @see GraphicsConfiguration
64 */
65 public class X11GraphicsEnvironment
66 extends SunGraphicsEnvironment
67 {
68 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11GraphicsEnvironment");
69 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.screen.X11GraphicsEnvironment");
70
71 private static Boolean xinerState;
72
73 static {
74 java.security.AccessController.doPrivileged(
75 new java.security.PrivilegedAction() {
76 public Object run() {
77 System.loadLibrary("awt");
78
79 /*
80 * Note: The MToolkit object depends on the static initializer
81 * of X11GraphicsEnvironment to initialize the connection to
82 * the X11 server.
83 */
84 if (!isHeadless()) {
85 // first check the OGL system property
86 boolean glxRequested = false;
87 String prop = System.getProperty("sun.java2d.opengl");
88 if (prop != null) {
89 if (prop.equals("true") || prop.equals("t")) {
90 glxRequested = true;
91 } else if (prop.equals("True") || prop.equals("T")) {
92 glxRequested = true;
93 glxVerbose = true;
94 }
95 }
237 if (isRemote != null) {
238 return isRemote.equals("false");
239 }
240
241 int shm = checkShmExt();
242 if (shm != -1) {
243 return (shm == 1);
244 }
245
246 // If XServer doesn't support ShMem extension,
247 // try the other way
248
249 String display = getDisplayString();
250 int ind = display.indexOf(':');
251 final String hostName = display.substring(0, ind);
252 if (ind <= 0) {
253 // ':0' case
254 return true;
255 }
256
257 Boolean result = (Boolean)java.security.AccessController.doPrivileged(
258 new java.security.PrivilegedAction() {
259 public Object run() {
260 InetAddress remAddr[] = null;
261 Enumeration locals = null;
262 Enumeration interfaces = null;
263 try {
264 interfaces = NetworkInterface.getNetworkInterfaces();
265 remAddr = InetAddress.getAllByName(hostName);
266 if (remAddr == null) {
267 return Boolean.FALSE;
268 }
269 } catch (UnknownHostException e) {
270 System.err.println("Unknown host: " + hostName);
271 return Boolean.FALSE;
272 } catch (SocketException e1) {
273 System.err.println(e1.getMessage());
274 return Boolean.FALSE;
275 }
276
277 for (; interfaces.hasMoreElements();) {
278 locals = ((NetworkInterface)interfaces.nextElement()).getInetAddresses();
279 for (; locals.hasMoreElements();) {
280 for (int i = 0; i < remAddr.length; i++) {
281 if (locals.nextElement().equals(remAddr[i])) {
282 return Boolean.TRUE;
283 }
284 }
285 }
286 }
287 return Boolean.FALSE;
288 }});
289 return result.booleanValue();
290 }
291
292
293
294 /**
295 * Returns face name for default font, or null if
296 * no face names are used for CompositeFontDescriptors
297 * for this platform.
298 */
|
55 import sun.java2d.xr.XRSurfaceData;
56
57 /**
58 * This is an implementation of a GraphicsEnvironment object for the
59 * default local GraphicsEnvironment used by the Java Runtime Environment
60 * for X11 environments.
61 *
62 * @see GraphicsDevice
63 * @see GraphicsConfiguration
64 */
65 public class X11GraphicsEnvironment
66 extends SunGraphicsEnvironment
67 {
68 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11GraphicsEnvironment");
69 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.screen.X11GraphicsEnvironment");
70
71 private static Boolean xinerState;
72
73 static {
74 java.security.AccessController.doPrivileged(
75 new java.security.PrivilegedAction<Object>() {
76 public Object run() {
77 System.loadLibrary("awt");
78
79 /*
80 * Note: The MToolkit object depends on the static initializer
81 * of X11GraphicsEnvironment to initialize the connection to
82 * the X11 server.
83 */
84 if (!isHeadless()) {
85 // first check the OGL system property
86 boolean glxRequested = false;
87 String prop = System.getProperty("sun.java2d.opengl");
88 if (prop != null) {
89 if (prop.equals("true") || prop.equals("t")) {
90 glxRequested = true;
91 } else if (prop.equals("True") || prop.equals("T")) {
92 glxRequested = true;
93 glxVerbose = true;
94 }
95 }
237 if (isRemote != null) {
238 return isRemote.equals("false");
239 }
240
241 int shm = checkShmExt();
242 if (shm != -1) {
243 return (shm == 1);
244 }
245
246 // If XServer doesn't support ShMem extension,
247 // try the other way
248
249 String display = getDisplayString();
250 int ind = display.indexOf(':');
251 final String hostName = display.substring(0, ind);
252 if (ind <= 0) {
253 // ':0' case
254 return true;
255 }
256
257 Boolean result = java.security.AccessController.doPrivileged(
258 new java.security.PrivilegedAction<Boolean>() {
259 public Boolean run() {
260 InetAddress remAddr[] = null;
261 Enumeration<InetAddress> locals = null;
262 Enumeration<NetworkInterface> interfaces = null;
263 try {
264 interfaces = NetworkInterface.getNetworkInterfaces();
265 remAddr = InetAddress.getAllByName(hostName);
266 if (remAddr == null) {
267 return Boolean.FALSE;
268 }
269 } catch (UnknownHostException e) {
270 System.err.println("Unknown host: " + hostName);
271 return Boolean.FALSE;
272 } catch (SocketException e1) {
273 System.err.println(e1.getMessage());
274 return Boolean.FALSE;
275 }
276
277 for (; interfaces.hasMoreElements();) {
278 locals = interfaces.nextElement().getInetAddresses();
279 for (; locals.hasMoreElements();) {
280 for (int i = 0; i < remAddr.length; i++) {
281 if (locals.nextElement().equals(remAddr[i])) {
282 return Boolean.TRUE;
283 }
284 }
285 }
286 }
287 return Boolean.FALSE;
288 }});
289 return result.booleanValue();
290 }
291
292
293
294 /**
295 * Returns face name for default font, or null if
296 * no face names are used for CompositeFontDescriptors
297 * for this platform.
298 */
|