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

Print this page
rev 6856 : RT-36822 [Monocle] X11 framebuffer container doesn't work any more

@@ -21,29 +21,56 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
+import com.sun.glass.ui.monocle.AcceleratedScreen;
 import com.sun.glass.ui.monocle.NativeCursor;
 import com.sun.glass.ui.monocle.NativePlatform;
 import com.sun.glass.ui.monocle.NativeScreen;
 import com.sun.glass.ui.monocle.NullCursor;
 import com.sun.glass.ui.monocle.input.InputDeviceRegistry;
+import com.sun.glass.ui.monocle.linux.LinuxInputDeviceRegistry;
+import com.sun.glass.ui.monocle.linux.LinuxSystem;
+import com.sun.glass.ui.monocle.mx6.MX6AcceleratedScreen;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 public class X11Platform extends NativePlatform {
 
+    private final boolean x11InputAndCursor;
+
+    public X11Platform() {
+        LinuxSystem.getLinuxSystem().loadLibrary();
+        x11InputAndCursor = AccessController.doPrivileged((PrivilegedAction<Boolean>)
+                () -> Boolean.getBoolean("x11.input"));
+    }
+
     @Override
     protected InputDeviceRegistry createInputDeviceRegistry() {
+        if (x11InputAndCursor) {
         return new X11InputDeviceRegistry();
+        } else {
+            return new LinuxInputDeviceRegistry(false);
+        }
     }
 
     @Override
     protected NativeCursor createCursor() {
         return new NullCursor();
     }
 
     @Override
     protected NativeScreen createScreen() {
-        return new X11Screen(true);
+        return new X11Screen(x11InputAndCursor);
     }
 
+    @Override
+    public synchronized AcceleratedScreen getAcceleratedScreen(
+            int[] attributes) {
+        if (accScreen == null) {
+            accScreen = new X11AcceleratedScreen(attributes);
+        }
+        return accScreen;
+    }
 }