mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
Split up Sys.openURL into the platform specific DisplayImplementation
This commit is contained in:
parent
23b6e400eb
commit
2577ffd377
7 changed files with 38 additions and 53 deletions
|
|
@ -34,6 +34,7 @@ package org.lwjgl;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
|
|
@ -238,36 +239,8 @@ public final class Sys {
|
|||
* @return false if we are CERTAIN the call has failed
|
||||
*/
|
||||
public static boolean openURL(String url) {
|
||||
String osName = System.getProperty("os.name");
|
||||
if (osName.startsWith("Mac OS") || osName.startsWith("Windows")) {
|
||||
// Mac and Windows both do this nicely from native code.
|
||||
nOpenURL(url);
|
||||
return true;
|
||||
}
|
||||
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
|
||||
// right anyway.
|
||||
|
||||
String[] browsers = {"mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
||||
|
||||
for (int i = 0; i < browsers.length; i ++) {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { browsers[i], url });
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
// Ignore
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
// Seems to have failed
|
||||
return false;
|
||||
return Display.getImplementation().openURL(url);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Where necessary, we use a native implementation of openURL.
|
||||
*/
|
||||
private static native void nOpenURL(String url);
|
||||
|
||||
/**
|
||||
* Get the contents of the system clipboard. The system might not have a clipboard
|
||||
|
|
|
|||
|
|
@ -237,4 +237,6 @@ public interface DisplayImplementation {
|
|||
|
||||
/* Pbuffer caps */
|
||||
public int getPbufferCaps();
|
||||
|
||||
public boolean openURL(String url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ package org.lwjgl.opengl;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
|
|
@ -102,4 +103,24 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
|
||||
public native void destroyCursor(Object cursorHandle);
|
||||
public native int getPbufferCaps();
|
||||
|
||||
public boolean openURL(String url) {
|
||||
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
|
||||
// right anyway.
|
||||
|
||||
String[] browsers = {"mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
|
||||
|
||||
for (int i = 0; i < browsers.length; i ++) {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { browsers[i], url });
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
// Ignore
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
// Seems to have failed
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -375,6 +375,10 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
return GL11.glGetString(GL11.GL_EXTENSIONS).indexOf("GL_APPLE_pixel_buffer") != -1 ? Pbuffer.PBUFFER_SUPPORTED : 0;
|
||||
}
|
||||
|
||||
public boolean openURL(String url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class captures com.apple.eawt.ApplicationEvents through reflection
|
||||
* to enable compilation on other platforms than Mac OS X
|
||||
|
|
|
|||
|
|
@ -102,4 +102,10 @@ final class Win32Display implements DisplayImplementation {
|
|||
|
||||
public native void destroyCursor(Object cursorHandle);
|
||||
public native int getPbufferCaps();
|
||||
public boolean openURL(String url) {
|
||||
nOpenURL(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
private native void nOpenURL(String url);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue