Windows: Moved NativeSysImplementation.java to WindowsSysImplementation.java and moved some native code to java.

This commit is contained in:
Elias Naur 2006-07-15 19:45:36 +00:00
parent 008c59a301
commit d9afe6b784
6 changed files with 32 additions and 133 deletions

View file

@ -57,7 +57,7 @@ public final class Sys {
private static final String VERSION = "1.0beta2";
/** Current version of the JNI library */
static final int JNI_VERSION = 2;
static final int JNI_VERSION = 3;
/** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation;
@ -114,7 +114,7 @@ public final class Sys {
class_name = "org.lwjgl.LinuxSysImplementation";
break;
case LWJGLUtil.PLATFORM_WINDOWS:
class_name = "org.lwjgl.Win32SysImplementation";
class_name = "org.lwjgl.WindowsSysImplementation";
break;
case LWJGLUtil.PLATFORM_MACOSX:
class_name = "org.lwjgl.MacOSXSysImplementation";

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2002-2004 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
/**
* <p>
* Win32 SysImplementation. This is just a straightforward NativsSysImplementation.
* </p>
* @author $Author$
* @version $Revision$
* $Id$
*/
class Win32SysImplementation extends NativeSysImplementation {
}

View file

@ -31,26 +31,43 @@
*/
package org.lwjgl;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
/**
* A SysImplementation that uses native calls only.
* <p>
* @author $Author$
* @version $Revision$
* $Id$
*/
class NativeSysImplementation extends DefaultSysImplementation {
class WindowsSysImplementation extends DefaultSysImplementation {
static {
Sys.initialize();
}
public native long getTimerResolution();
public long getTimerResolution() {
return 1000;
}
public native long getTime();
public native void alert(String title, String message);
public native boolean openURL(String url);
public boolean openURL(final String url) {
try {
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
Runtime.getRuntime().exec(new String[]{"rundll32", "url.dll,FileProtocolHandler", url});
return null;
}
});
return true;
} catch (PrivilegedActionException e) {
LWJGLUtil.log("Failed to open url (" + url + "): " + e.getCause().getMessage());
return false;
}
}
public native String getClipboard();
}

View file

@ -69,6 +69,7 @@ public class DisplayTest {
System.out.println("Info about current:");
System.out.println("Graphics card: " + Display.getAdapter() + ", version: " + Display.getVersion());
System.exit(1);
System.out.println("Resolution: " +
Display.getDisplayMode().getWidth() + "x" +
Display.getDisplayMode().getHeight() + "x" +