Skip to content

Commit e740faf

Browse files
committed
fix: add 'isWaylandSession'
1 parent 746f5a0 commit e740faf

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

jme3-core/src/main/java/com/jme3/system/JmeSystem.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ public static Platform getPlatform() {
190190
return systemDelegate.getPlatform();
191191
}
192192

193+
/**
194+
* Detects if you are in a Wayland session.
195+
*
196+
* @return {@code true} if you are in a Wayland session, otherwise it will
197+
* be {@code false}
198+
*/
199+
public static boolean isWaylandSession() {
200+
checkDelegate();
201+
return systemDelegate.isWaylandSession();
202+
}
203+
193204
public static JmeContext newContext(AppSettings settings, JmeContext.Type contextType) {
194205
checkDelegate();
195206
return systemDelegate.newContext(settings, contextType);

jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ public Platform getPlatform() {
309309
}
310310
}
311311

312+
public boolean isWaylandSession() {
313+
// The following matches the test GLFW does to enable the Wayland backend.
314+
if ("wayland".equalsIgnoreCase(System.getenv("XDG_SESSION_TYPE")) && System.getenv("WAYLAND_DISPLAY") != null) {
315+
return true;
316+
}
317+
return false;
318+
}
319+
312320
public String getBuildInfo() {
313321
StringBuilder sb = new StringBuilder();
314322
sb.append("Running on ").append(getFullName()).append("\n");

0 commit comments

Comments
 (0)