summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com
diff options
context:
space:
mode:
authorErik De Rijcke <[email protected]>2015-05-06 16:30:42 +0200
committerSven Gothel <[email protected]>2019-11-21 03:28:50 +0100
commitf4281b5ee80d7674134bfee357695a98382884a3 (patch)
treee54ad95c7e67505d9605de2a988eed1350ed7f59 /src/nativewindow/classes/com
parentcd07cb251ae2df8e8cfd455a91cbe7d5394a77e0 (diff)
detect gbm platform on linux when no other display server is running
Diffstat (limited to 'src/nativewindow/classes/com')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java48
1 files changed, 43 insertions, 5 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
index 63063bef7..5539a13b1 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java
@@ -33,6 +33,7 @@
package com.jogamp.nativewindow;
+import java.io.File;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -43,14 +44,12 @@ import java.util.List;
import java.util.Map;
import com.jogamp.nativewindow.util.Point;
-import com.jogamp.nativewindow.util.PointImmutable;
-
import jogamp.common.os.PlatformPropsImpl;
import jogamp.nativewindow.BcmVCArtifacts;
import jogamp.nativewindow.Debug;
import jogamp.nativewindow.NativeWindowFactoryImpl;
-import jogamp.nativewindow.ToolkitProperties;
import jogamp.nativewindow.ResourceToolkitLock;
+import jogamp.nativewindow.ToolkitProperties;
import jogamp.nativewindow.WrappedWindow;
import jogamp.nativewindow.ios.IOSUtil;
import jogamp.nativewindow.macosx.OSXUtil;
@@ -84,6 +83,12 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public abstract class NativeWindowFactory {
protected static final boolean DEBUG;
+ /** Wayland/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_WAYLAND = ".wayland";
+
+ /** GBM/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
+ public static final String TYPE_GBM = ".gbm";
+
/** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/
public static final String TYPE_EGL = ".egl";
@@ -156,7 +161,6 @@ public abstract class NativeWindowFactory {
return TYPE_WINDOWS;
case OPENKODE:
return TYPE_EGL;
-
case LINUX:
case FREEBSD:
case SUNOS:
@@ -165,10 +169,44 @@ public abstract class NativeWindowFactory {
if( BcmVCArtifacts.guessVCIVUsed() ) {
return TYPE_BCM_VC_IV;
}
- return TYPE_X11;
+ if(guessX()){
+ return TYPE_X11;
+ }
+ if(guessWayland()){
+ //TODO
+ return TYPE_WAYLAND;
+ }
+ if(guessGBM()){
+ return TYPE_GBM;
+ }
+ return TYPE_DEFAULT;
}
}
+ private static boolean guessX() {
+ return System.getProperty("DISPLAY") !=null;
+ }
+
+ private static boolean guessWayland() {
+ //TODO we can/should do a more elaborate check and try looking for a wayland-0 socket in $XDG_RUNTIME_DIR
+ return System.getProperty("WAYLAND_DISPLAY") !=null;
+ }
+
+ private static boolean guessGBM() {
+ //FIXME this is not the best way to check if we have gbm-egl support, but does a good easy way actually exist?
+ return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ private final File vcliblocation = new File(
+ "/dev/dri/card0");
+ @Override
+ public Boolean run() {
+ if ( vcliblocation.isFile() ) {
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+ }
+ } ).booleanValue();
+ }
+
static {
final boolean[] _DEBUG = new boolean[] { false };
final String[] _tmp = new String[] { null };