modules/graphics/src/main/java/com/sun/glass/ui/monocle/x11/X11PlatformFactory.java

Print this page
rev 6978 : RT-37065 [Monocle] Use the X11 implementation in preference to framebuffer if DISPLAY is set

@@ -26,15 +26,20 @@
 package com.sun.glass.ui.monocle.x11;
 
 import com.sun.glass.ui.monocle.NativePlatform;
 import com.sun.glass.ui.monocle.NativePlatformFactory;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public class X11PlatformFactory extends NativePlatformFactory {
 
     @Override
     protected boolean matches() {
-        return true;
+        String display = AccessController.doPrivileged(
+                (PrivilegedAction<String>) () -> System.getenv("DISPLAY"));
+        return display != null;
     }
 
     @Override
     protected NativePlatform createNativePlatform() {
         return new X11Platform();