Misc fixes and improvements on Windows:
- Cleaned up cl flags and enabled parallel compilation. Native compilation is now multiple times faster. - Fixed all /W3 compilation warnings. - Changed window flag from WS_CHILDWINDOW to WS_POPUP when Display.setParent is used, in an attempt to fix focus-related issues.
This commit is contained in:
parent
62b8d36002
commit
5400bb27db
18
build.xml
18
build.xml
|
@ -284,7 +284,7 @@
|
||||||
|
|
||||||
<!-- Generates the native headers from source files -->
|
<!-- Generates the native headers from source files -->
|
||||||
<target name="headers" description="invokes javah on java classes" depends="compile">
|
<target name="headers" description="invokes javah on java classes" depends="compile">
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux">
|
||||||
<class name="org.lwjgl.LinuxSysImplementation" />
|
<class name="org.lwjgl.LinuxSysImplementation" />
|
||||||
<class name="org.lwjgl.opengl.LinuxEvent" />
|
<class name="org.lwjgl.opengl.LinuxEvent" />
|
||||||
<class name="org.lwjgl.opengl.LinuxMouse" />
|
<class name="org.lwjgl.opengl.LinuxMouse" />
|
||||||
|
@ -293,7 +293,7 @@
|
||||||
<class name="org.lwjgl.opengl.LinuxPeerInfo" />
|
<class name="org.lwjgl.opengl.LinuxPeerInfo" />
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl">
|
||||||
<class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/>
|
<class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/>
|
||||||
<class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/>
|
<class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/>
|
||||||
<class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/>
|
<class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/>
|
||||||
|
@ -301,7 +301,7 @@
|
||||||
<class name="org.lwjgl.opengl.LinuxCanvasImplementation"/>
|
<class name="org.lwjgl.opengl.LinuxCanvasImplementation"/>
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows">
|
||||||
<class name="org.lwjgl.WindowsSysImplementation"/>
|
<class name="org.lwjgl.WindowsSysImplementation"/>
|
||||||
<class name="org.lwjgl.opengl.WindowsKeyboard" />
|
<class name="org.lwjgl.opengl.WindowsKeyboard" />
|
||||||
<class name="org.lwjgl.opengl.WindowsRegistry" />
|
<class name="org.lwjgl.opengl.WindowsRegistry" />
|
||||||
|
@ -310,17 +310,17 @@
|
||||||
<class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/>
|
<class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/>
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl">
|
||||||
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
|
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
|
||||||
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
||||||
<class name="org.lwjgl.opengl.WindowsContextImplementation"/>
|
<class name="org.lwjgl.opengl.WindowsContextImplementation"/>
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles">
|
||||||
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx">
|
||||||
<class name="org.lwjgl.MacOSXSysImplementation" />
|
<class name="org.lwjgl.MacOSXSysImplementation" />
|
||||||
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
|
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
|
||||||
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
|
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
|
||||||
|
@ -330,7 +330,7 @@
|
||||||
<class name="org.lwjgl.opengl.MacOSXContextImplementation" />
|
<class name="org.lwjgl.opengl.MacOSXContextImplementation" />
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}">
|
||||||
<class name="org.lwjgl.opengl.AWTSurfaceLock" />
|
<class name="org.lwjgl.opengl.AWTSurfaceLock" />
|
||||||
<class name="org.lwjgl.DefaultSysImplementation" />
|
<class name="org.lwjgl.DefaultSysImplementation" />
|
||||||
<class name="org.lwjgl.input.Cursor" />
|
<class name="org.lwjgl.input.Cursor" />
|
||||||
|
@ -342,7 +342,7 @@
|
||||||
<class name="org.lwjgl.BufferUtils" />
|
<class name="org.lwjgl.BufferUtils" />
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengl" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengl">
|
||||||
<class name="org.lwjgl.opengl.GLContext"/>
|
<class name="org.lwjgl.opengl.GLContext"/>
|
||||||
<class name="org.lwjgl.opengl.Pbuffer"/>
|
<class name="org.lwjgl.opengl.Pbuffer"/>
|
||||||
<class name="org.lwjgl.opengl.CallbackUtil"/>
|
<class name="org.lwjgl.opengl.CallbackUtil"/>
|
||||||
|
@ -350,7 +350,7 @@
|
||||||
<class name="org.lwjgl.opengl.NVVideoCaptureUtil"/>
|
<class name="org.lwjgl.opengl.NVVideoCaptureUtil"/>
|
||||||
</javah>
|
</javah>
|
||||||
|
|
||||||
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles" force="yes">
|
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles">
|
||||||
<class name="org.lwjgl.opengles.EGL"/>
|
<class name="org.lwjgl.opengles.EGL"/>
|
||||||
<class name="org.lwjgl.opengles.EGLKHRFenceSync"/>
|
<class name="org.lwjgl.opengles.EGLKHRFenceSync"/>
|
||||||
<class name="org.lwjgl.opengles.EGLKHRReusableSync"/>
|
<class name="org.lwjgl.opengles.EGLKHRReusableSync"/>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<project name="generator">
|
<project name="generator">
|
||||||
|
|
||||||
|
<import file="build-definitions.xml"/>
|
||||||
|
|
||||||
<!-- clean the generated files -->
|
<!-- clean the generated files -->
|
||||||
<target name="clean-generated" description="Deletes the generated java source">
|
<target name="clean-generated" description="Deletes the generated java source">
|
||||||
<delete quiet="true" failonerror="false">
|
<delete quiet="true" failonerror="false">
|
||||||
|
@ -20,7 +22,7 @@
|
||||||
<include name="org/lwjgl/util/generator/opengl/**.java"/>
|
<include name="org/lwjgl/util/generator/opengl/**.java"/>
|
||||||
<include name="org/lwjgl/util/generator/opengles/**.java"/>
|
<include name="org/lwjgl/util/generator/opengles/**.java"/>
|
||||||
<include name="org/lwjgl/util/generator/opencl/**.java"/>
|
<include name="org/lwjgl/util/generator/opencl/**.java"/>
|
||||||
<compilerarg value="-Xlint:all"/>
|
<compilerarg value="-Xlint:none"/>
|
||||||
</javac>
|
</javac>
|
||||||
<!-- Compile helper classes used by the templates -->
|
<!-- Compile helper classes used by the templates -->
|
||||||
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
|
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<property name="sdkhome" location="${env.MSSDK}"/>
|
<property name="sdkhome" location="${env.MSSDK}"/>
|
||||||
|
|
||||||
<target name="compile_dir">
|
<target name="compile_dir">
|
||||||
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
|
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
|
||||||
<arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
|
<arg line="/c /W3 /EHsc /Ox /Gy /MT /MP /nologo"/>
|
||||||
<arg value="/I${sdkhome}\include"/>
|
<arg value="/I${sdkhome}\include"/>
|
||||||
<arg value="/I${java.home}\..\include"/>
|
<arg value="/I${java.home}\..\include"/>
|
||||||
<arg value="/I${java.home}\..\include\win32"/>
|
<arg value="/I${java.home}\..\include\win32"/>
|
||||||
|
|
|
@ -58,6 +58,7 @@ import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public final class Display {
|
public final class Display {
|
||||||
|
|
||||||
|
@ -121,6 +122,12 @@ public final class Display {
|
||||||
private static float r, g, b;
|
private static float r, g, b;
|
||||||
|
|
||||||
private static final ComponentListener component_listener = new ComponentAdapter() {
|
private static final ComponentListener component_listener = new ComponentAdapter() {
|
||||||
|
public void componentMoved(ComponentEvent e) {
|
||||||
|
synchronized ( GlobalLock.lock ) {
|
||||||
|
parent_resized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
synchronized ( GlobalLock.lock ) {
|
synchronized ( GlobalLock.lock ) {
|
||||||
parent_resized = true;
|
parent_resized = true;
|
||||||
|
@ -298,6 +305,7 @@ public final class Display {
|
||||||
throw new LWJGLException("Parent.isDisplayable() must be true");
|
throw new LWJGLException("Parent.isDisplayable() must be true");
|
||||||
if ( tmp_parent != null ) {
|
if ( tmp_parent != null ) {
|
||||||
tmp_parent.addComponentListener(component_listener);
|
tmp_parent.addComponentListener(component_listener);
|
||||||
|
SwingUtilities.windowForComponent(parent).addComponentListener(component_listener);
|
||||||
}
|
}
|
||||||
DisplayMode mode = getEffectiveMode();
|
DisplayMode mode = getEffectiveMode();
|
||||||
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
|
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
|
||||||
|
@ -335,6 +343,7 @@ public final class Display {
|
||||||
}
|
}
|
||||||
if ( parent != null ) {
|
if ( parent != null ) {
|
||||||
parent.removeComponentListener(component_listener);
|
parent.removeComponentListener(component_listener);
|
||||||
|
SwingUtilities.windowForComponent(parent).removeComponentListener(component_listener);
|
||||||
}
|
}
|
||||||
releaseDrawable();
|
releaseDrawable();
|
||||||
|
|
||||||
|
@ -401,7 +410,7 @@ public final class Display {
|
||||||
/**
|
/**
|
||||||
* An accurate sync method that will attempt to run at a constant frame rate.
|
* An accurate sync method that will attempt to run at a constant frame rate.
|
||||||
* It should be called once every frame.
|
* It should be called once every frame.
|
||||||
*
|
*
|
||||||
* @param fps - the desired frame rate, in frames per second
|
* @param fps - the desired frame rate, in frames per second
|
||||||
*/
|
*/
|
||||||
public static void sync(int fps) {
|
public static void sync(int fps) {
|
||||||
|
@ -1257,7 +1266,7 @@ public final class Display {
|
||||||
* @return this method will return the x position (top-left) of the Display window.
|
* @return this method will return the x position (top-left) of the Display window.
|
||||||
*
|
*
|
||||||
* If running in fullscreen mode it will return 0.
|
* If running in fullscreen mode it will return 0.
|
||||||
* If Display.setParent(Canvas parent) is being used, the x position of
|
* If Display.setParent(Canvas parent) is being used, the x position of
|
||||||
* the parent will be returned.
|
* the parent will be returned.
|
||||||
*/
|
*/
|
||||||
public static int getX() {
|
public static int getX() {
|
||||||
|
@ -1272,12 +1281,12 @@ public final class Display {
|
||||||
|
|
||||||
return display_impl.getX();
|
return display_impl.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return this method will return the y position (top-left) of the Display window.
|
* @return this method will return the y position (top-left) of the Display window.
|
||||||
*
|
*
|
||||||
* If running in fullscreen mode it will return 0.
|
* If running in fullscreen mode it will return 0.
|
||||||
* If Display.setParent(Canvas parent) is being used, the y position of
|
* If Display.setParent(Canvas parent) is being used, the y position of
|
||||||
* the parent will be returned.
|
* the parent will be returned.
|
||||||
*/
|
*/
|
||||||
public static int getY() {
|
public static int getY() {
|
||||||
|
@ -1292,7 +1301,7 @@ public final class Display {
|
||||||
|
|
||||||
return display_impl.getY();
|
return display_impl.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return this method will return the width of the Display window.
|
* @return this method will return the width of the Display window.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,8 +38,9 @@ package org.lwjgl.opengl;
|
||||||
* @author elias_naur
|
* @author elias_naur
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
import java.awt.Canvas;
|
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.LWJGLUtil;
|
import org.lwjgl.LWJGLUtil;
|
||||||
|
@ -49,6 +50,8 @@ import org.lwjgl.input.Cursor;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengles.EGL;
|
import org.lwjgl.opengles.EGL;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
final class WindowsDisplay implements DisplayImplementation {
|
final class WindowsDisplay implements DisplayImplementation {
|
||||||
private static final int GAMMA_LENGTH = 256;
|
private static final int GAMMA_LENGTH = 256;
|
||||||
|
|
||||||
|
@ -150,9 +153,9 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
private static final int WS_THICKFRAME = 0x00040000;
|
private static final int WS_THICKFRAME = 0x00040000;
|
||||||
private static final int WS_MAXIMIZEBOX = 0x00010000;
|
private static final int WS_MAXIMIZEBOX = 0x00010000;
|
||||||
|
|
||||||
private static final int HTCLIENT = 0x01;
|
private static final int HTCLIENT = 0x01;
|
||||||
|
|
||||||
private static final int MK_XBUTTON1 = 0x0020;
|
private static final int MK_XBUTTON1 = 0x0020;
|
||||||
private static final int MK_XBUTTON2 = 0x0040;
|
private static final int MK_XBUTTON2 = 0x0040;
|
||||||
private static final int XBUTTON1 = 0x0001;
|
private static final int XBUTTON1 = 0x0001;
|
||||||
|
@ -199,6 +202,15 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
private boolean trackingMouse;
|
private boolean trackingMouse;
|
||||||
private boolean mouseInside;
|
private boolean mouseInside;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
final Method windowProc = WindowsDisplay.class.getDeclaredMethod("handleMessage", long.class, int.class, long.class, long.class, long.class);
|
||||||
|
setWindowProc(windowProc);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WindowsDisplay() {
|
WindowsDisplay() {
|
||||||
current_display = this;
|
current_display = this;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +224,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
maximized = false;
|
maximized = false;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
hasParent = parent != null;
|
hasParent = parent != null;
|
||||||
long parent_hwnd = parent != null ? getHwnd(parent) : 0;
|
long parent_hwnd = parent != null ? nGetParent(getHwnd(parent)) : 0;
|
||||||
this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
|
this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
|
||||||
this.resizable=false;
|
this.resizable=false;
|
||||||
if (hwnd == 0) {
|
if (hwnd == 0) {
|
||||||
|
@ -233,6 +245,8 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
((DrawableGLES)drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat());
|
((DrawableGLES)drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat)drawable.getPixelFormat());
|
||||||
}
|
}
|
||||||
peer_info.initDC(getHwnd(), getHdc());
|
peer_info.initDC(getHwnd(), getHdc());
|
||||||
|
if ( parent != null )
|
||||||
|
reshape(0, 0, mode.getWidth(), mode.getHeight());
|
||||||
showWindow(getHwnd(), SW_SHOWDEFAULT);
|
showWindow(getHwnd(), SW_SHOWDEFAULT);
|
||||||
|
|
||||||
updateWidthAndHeight();
|
updateWidthAndHeight();
|
||||||
|
@ -275,6 +289,8 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static native long nGetParent(long hWnd);
|
||||||
|
|
||||||
public void destroyWindow() {
|
public void destroyWindow() {
|
||||||
nReleaseDC(hwnd, hdc);
|
nReleaseDC(hwnd, hdc);
|
||||||
nDestroyWindow(hwnd);
|
nDestroyWindow(hwnd);
|
||||||
|
@ -496,9 +512,6 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
nUpdate();
|
nUpdate();
|
||||||
if (parent != null && parent.isFocusOwner()) {
|
|
||||||
setFocus(getHwnd());
|
|
||||||
}
|
|
||||||
if (redoMakeContextCurrent) {
|
if (redoMakeContextCurrent) {
|
||||||
redoMakeContextCurrent = false;
|
redoMakeContextCurrent = false;
|
||||||
/**
|
/**
|
||||||
|
@ -518,6 +531,15 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
private static native void nUpdate();
|
private static native void nUpdate();
|
||||||
|
|
||||||
public void reshape(int x, int y, int width, int height) {
|
public void reshape(int x, int y, int width, int height) {
|
||||||
|
if ( parent != null ) {
|
||||||
|
// Translate canvas location to screen coordinates
|
||||||
|
Point p = new Point();
|
||||||
|
|
||||||
|
SwingUtilities.convertPointToScreen(p, parent);
|
||||||
|
|
||||||
|
x += p.getX();
|
||||||
|
y += p.getY();
|
||||||
|
}
|
||||||
nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null);
|
nReshape(getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null);
|
||||||
}
|
}
|
||||||
private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child);
|
private static native void nReshape(long hwnd, int x, int y, int width, int height, boolean undecorated, boolean child);
|
||||||
|
@ -780,10 +802,6 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
nReleaseCapture();
|
nReleaseCapture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent != null && !isFocused) {
|
|
||||||
setFocus(getHwnd());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldGrab() {
|
private boolean shouldGrab() {
|
||||||
|
@ -833,14 +851,16 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
private static native void clientToScreen(long hwnd, IntBuffer point);
|
private static native void clientToScreen(long hwnd, IntBuffer point);
|
||||||
|
|
||||||
private static int handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
private static native void setWindowProc(Method windowProc);
|
||||||
|
|
||||||
|
private static long handleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||||
if (current_display != null)
|
if (current_display != null)
|
||||||
return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
|
return current_display.doHandleMessage(hwnd, msg, wParam, lParam, millis);
|
||||||
else
|
else
|
||||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native int defWindowProc(long hwnd, int msg, long wParam, long lParam);
|
private static native long defWindowProc(long hwnd, int msg, long wParam, long lParam);
|
||||||
|
|
||||||
private void checkCursorState() {
|
private void checkCursorState() {
|
||||||
updateClipping();
|
updateClipping();
|
||||||
|
@ -863,7 +883,12 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
checkCursorState();
|
checkCursorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
private long doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
|
||||||
|
if ( hwnd != getHwnd() ) {
|
||||||
|
// Can happen at start-up
|
||||||
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
// disable screen saver and monitor power down messages which wreak havoc
|
// disable screen saver and monitor power down messages which wreak havoc
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
|
@ -876,7 +901,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
appActivate(false);
|
appActivate(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
switch ((int)wParam) {
|
switch ((int)wParam) {
|
||||||
case SIZE_RESTORED:
|
case SIZE_RESTORED:
|
||||||
|
@ -908,13 +933,13 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
} else {
|
} else {
|
||||||
// let Windows handle cursors outside the client area for resizing, etc.
|
// let Windows handle cursors outside the client area for resizing, etc.
|
||||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
appActivate(false);
|
appActivate(false);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
appActivate(true);
|
appActivate(true);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
int xPos = (int)(short)(lParam & 0xFFFF);
|
int xPos = (int)(short)(lParam & 0xFFFF);
|
||||||
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
|
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
|
||||||
|
@ -924,29 +949,29 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
if(!trackingMouse) {
|
if(!trackingMouse) {
|
||||||
trackingMouse = nTrackMouseEvent(hwnd);
|
trackingMouse = nTrackMouseEvent(hwnd);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
|
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);
|
||||||
handleMouseScrolled(dwheel, millis);
|
handleMouseScrolled(dwheel, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
handleMouseButton(0, 1, millis);
|
handleMouseButton(0, 1, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
handleMouseButton(0, 0, millis);
|
handleMouseButton(0, 0, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
handleMouseButton(1, 1, millis);
|
handleMouseButton(1, 1, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
handleMouseButton(1, 0, millis);
|
handleMouseButton(1, 0, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
handleMouseButton(2, 1, millis);
|
handleMouseButton(2, 1, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
handleMouseButton(2, 0, millis);
|
handleMouseButton(2, 0, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
if((wParam >> 16) == XBUTTON1) {
|
if((wParam >> 16) == XBUTTON1) {
|
||||||
handleMouseButton(3, 0, millis);
|
handleMouseButton(3, 0, millis);
|
||||||
|
@ -964,7 +989,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
case WM_SYSCHAR:
|
case WM_SYSCHAR:
|
||||||
case WM_CHAR:
|
case WM_CHAR:
|
||||||
handleChar(wParam, lParam, millis);
|
handleChar(wParam, lParam, millis);
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_SYSKEYUP:
|
case WM_SYSKEYUP:
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
@ -985,17 +1010,17 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
close_requested = true;
|
close_requested = true;
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
switch ((int)(wParam & 0xfff0)) {
|
switch ((int)(wParam & 0xfff0)) {
|
||||||
case SC_KEYMENU:
|
case SC_KEYMENU:
|
||||||
case SC_MOUSEMENU:
|
case SC_MOUSEMENU:
|
||||||
case SC_SCREENSAVE:
|
case SC_SCREENSAVE:
|
||||||
case SC_MONITORPOWER:
|
case SC_MONITORPOWER:
|
||||||
return 0;
|
return 0L;
|
||||||
case SC_CLOSE:
|
case SC_CLOSE:
|
||||||
close_requested = true;
|
close_requested = true;
|
||||||
return 0;
|
return 0L;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1015,7 +1040,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
handleMouseButton(captureMouse, 0, millis);
|
handleMouseButton(captureMouse, 0, millis);
|
||||||
captureMouse = -1;
|
captureMouse = -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0L;
|
||||||
case WM_WINDOWPOSCHANGED:
|
case WM_WINDOWPOSCHANGED:
|
||||||
if(getWindowRect(hwnd, rect_buffer)) {
|
if(getWindowRect(hwnd, rect_buffer)) {
|
||||||
rect.copyFromBuffer(rect_buffer);
|
rect.copyFromBuffer(rect_buffer);
|
||||||
|
@ -1024,12 +1049,12 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
} else {
|
} else {
|
||||||
LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
|
LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
|
||||||
}
|
}
|
||||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
default:
|
default:
|
||||||
return defWindowProc(hwnd, msg, wParam, lParam);
|
return defWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer);
|
private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer);
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
|
@ -1056,8 +1081,8 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
|
|
||||||
public void setResizable(boolean resizable) {
|
public void setResizable(boolean resizable) {
|
||||||
if(this.resizable != resizable) {
|
if(this.resizable != resizable) {
|
||||||
long style = getWindowLongPtr(hwnd, GWL_STYLE);
|
int style = (int)getWindowLongPtr(hwnd, GWL_STYLE);
|
||||||
long styleex = getWindowLongPtr(hwnd, GWL_EXSTYLE);
|
int styleex = (int)getWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||||
|
|
||||||
// update frame style
|
// update frame style
|
||||||
if(resizable && !Display.isFullscreen()) {
|
if(resizable && !Display.isFullscreen()) {
|
||||||
|
@ -1082,7 +1107,7 @@ final class WindowsDisplay implements DisplayImplementation {
|
||||||
this.resizable = resizable;
|
this.resizable = resizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native boolean adjustWindowRectEx(IntBuffer rectBuffer, long style, boolean menu, long styleex);
|
private native boolean adjustWindowRectEx(IntBuffer rectBuffer, int style, boolean menu, int styleex);
|
||||||
|
|
||||||
public boolean wasResized() {
|
public boolean wasResized() {
|
||||||
if(resized) {
|
if(resized) {
|
||||||
|
|
|
@ -324,7 +324,7 @@ public class NativeMethodStubsGenerator {
|
||||||
|
|
||||||
// Declare loop counters and allocate object array
|
// Declare loop counters and allocate object array
|
||||||
if ( !ptrLoopDeclared ) {
|
if ( !ptrLoopDeclared ) {
|
||||||
writer.println("\tunsigned int " + n + "_i;");
|
writer.println("\tint " + n + "_i;");
|
||||||
writer.println("\tjobject " + n + "_object;");
|
writer.println("\tjobject " + n + "_object;");
|
||||||
ptrLoopDeclared = true;
|
ptrLoopDeclared = true;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ public class NativeMethodStubsGenerator {
|
||||||
|
|
||||||
// Declare loop counters and allocate string array
|
// Declare loop counters and allocate string array
|
||||||
if ( !strLoopDeclared ) {
|
if ( !strLoopDeclared ) {
|
||||||
writer.println("\tunsigned int " + n + "_i;");
|
writer.println("\tint " + n + "_i;");
|
||||||
writer.println("\t" + arrayType + n + "_address;");
|
writer.println("\t" + arrayType + n + "_address;");
|
||||||
strLoopDeclared = true;
|
strLoopDeclared = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,11 +227,11 @@ jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *ustr) {
|
||||||
const char *str = (const char *)ustr;
|
const char *str = (const char *)ustr;
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return NewStringNativeWithLength(env, str, strlen(str));
|
return NewStringNativeWithLength(env, str, (jsize)strlen(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates locale specific string
|
// creates locale specific string
|
||||||
jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length) {
|
jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length) {
|
||||||
jclass jcls_str;
|
jclass jcls_str;
|
||||||
jmethodID jmethod_str;
|
jmethodID jmethod_str;
|
||||||
jstring result;
|
jstring result;
|
||||||
|
@ -330,7 +330,7 @@ void ext_InitializeClass(JNIEnv *env, jclass clazz, ExtGetProcAddressPROC gpa, i
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getBooleanProperty(JNIEnv *env, const char* propertyName) {
|
bool getBooleanProperty(JNIEnv *env, const char* propertyName) {
|
||||||
jstring property = NewStringNativeWithLength(env, propertyName, strlen(propertyName));
|
jstring property = NewStringNativeWithLength(env, propertyName, (jsize)strlen(propertyName));
|
||||||
jclass org_lwjgl_LWJGLUtil_class;
|
jclass org_lwjgl_LWJGLUtil_class;
|
||||||
jmethodID getBoolean;
|
jmethodID getBoolean;
|
||||||
if (property == NULL)
|
if (property == NULL)
|
||||||
|
|
|
@ -75,18 +75,18 @@ static inline void * safeGetBufferAddress(JNIEnv *env, jobject buffer) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline jobject safeNewBuffer(JNIEnv *env, void *p, int size) {
|
static inline jobject safeNewBuffer(JNIEnv *env, void *p, jlong capacity) {
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
return env->NewDirectByteBuffer(p, size);
|
return env->NewDirectByteBuffer(p, capacity);
|
||||||
#else
|
#else
|
||||||
return (*env)->NewDirectByteBuffer(env, p, size);
|
return (*env)->NewDirectByteBuffer(env, p, capacity);
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline jobject safeNewBufferCached(JNIEnv *env, void *p, int size, jobject old_buffer) {
|
static inline jobject safeNewBufferCached(JNIEnv *env, void *p, jlong size, jobject old_buffer) {
|
||||||
if (old_buffer != NULL) {
|
if (old_buffer != NULL) {
|
||||||
void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer);
|
void *old_buffer_address = (*env)->GetDirectBufferAddress(env, old_buffer);
|
||||||
jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer);
|
jlong capacity = (*env)->GetDirectBufferCapacity(env, old_buffer);
|
||||||
|
@ -141,7 +141,7 @@ extern void printfDebugJava(JNIEnv *env, const char *format, ...);
|
||||||
extern void printfDebug(const char *format, ...);
|
extern void printfDebug(const char *format, ...);
|
||||||
extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
|
extern bool getBooleanProperty(JNIEnv *env, const char* propertyName);
|
||||||
extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
|
extern char * GetStringNativeChars(JNIEnv *env, jstring jstr);
|
||||||
extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, int length);
|
extern jstring NewStringNativeWithLength(JNIEnv *env, const char *str, jsize length);
|
||||||
extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
|
extern jstring NewStringNativeUnsigned(JNIEnv *env, const unsigned char *str);
|
||||||
extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity);
|
extern jobject NewReadOnlyDirectByteBuffer(JNIEnv* env, const void* address, jlong capacity);
|
||||||
extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
|
extern jobject newJavaManagedByteBuffer(JNIEnv *env, const int size);
|
||||||
|
|
|
@ -59,7 +59,7 @@ void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMet
|
||||||
ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions);
|
ext_InitializeClass(env, clazz, &extcl_GetProcAddress, num_functions, functions);
|
||||||
}
|
}
|
||||||
|
|
||||||
int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) {
|
size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch) {
|
||||||
if ( slice_pitch == 0 )
|
if ( slice_pitch == 0 )
|
||||||
return region[1] * row_pitch;
|
return region[1] * row_pitch;
|
||||||
else
|
else
|
||||||
|
|
|
@ -70,7 +70,7 @@ typedef void (CL_CALLBACK * cl_printf_callback)(cl_context context, cl_uint prin
|
||||||
|
|
||||||
void* extcl_GetProcAddress(const char* function);
|
void* extcl_GetProcAddress(const char* function);
|
||||||
void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
|
void extcl_InitializeClass(JNIEnv *env, jclass clazz, int num_functions, JavaMethodAndExtFunction *functions);
|
||||||
int extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch);
|
size_t extcl_CalculateImageSize(const size_t *region, size_t row_pitch, size_t slice_pitch);
|
||||||
|
|
||||||
// -----------------[ Platform dependent functions ]-----------------
|
// -----------------[ Platform dependent functions ]-----------------
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ static alcGetEnumValuePROC alcGetEnumValue;
|
||||||
*/
|
*/
|
||||||
static jobject JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) {
|
static jobject JNICALL Java_org_lwjgl_openal_ALC10_nalcGetString (JNIEnv *env, jclass clazz, jlong deviceaddress, jint token) {
|
||||||
char* alcString = (char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token);
|
char* alcString = (char*) alcGetString((ALCdevice*)((intptr_t)deviceaddress), (ALenum) token);
|
||||||
int length;
|
size_t length;
|
||||||
int i=1;
|
int i=1;
|
||||||
|
|
||||||
if (alcString == NULL) {
|
if (alcString == NULL) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void CL_CALLBACK contextCallback(const char *errinfo, const void *private
|
||||||
private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb);
|
private_info_buffer = NewReadOnlyDirectByteBuffer(env, private_info, cb);
|
||||||
|
|
||||||
(*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ,
|
(*env)->CallVoidMethod(env, (jobject)user_data, contextCallbackJ,
|
||||||
NewStringNativeWithLength(env, errinfo, strlen(errinfo)),
|
NewStringNativeWithLength(env, errinfo, (jsize)strlen(errinfo)),
|
||||||
private_info_buffer
|
private_info_buffer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ jobject convertToNativeRamp(JNIEnv *env, jobject float_gamma_obj) {
|
||||||
float scaledRampEntry;
|
float scaledRampEntry;
|
||||||
WORD rampEntry;
|
WORD rampEntry;
|
||||||
const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj);
|
const float *gammaRamp = (const float *)(*env)->GetDirectBufferAddress(env, float_gamma_obj);
|
||||||
jint gamma_ramp_length = (*env)->GetDirectBufferCapacity(env, float_gamma_obj);
|
jint gamma_ramp_length = (jint)(*env)->GetDirectBufferCapacity(env, float_gamma_obj);
|
||||||
jobject native_ramp;
|
jobject native_ramp;
|
||||||
WORD *native_ramp_buffer;
|
WORD *native_ramp_buffer;
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool undec
|
||||||
windowflags = WS_POPUP;
|
windowflags = WS_POPUP;
|
||||||
} else if (child_window) {
|
} else if (child_window) {
|
||||||
exstyle = 0;
|
exstyle = 0;
|
||||||
windowflags = WS_CHILDWINDOW;
|
windowflags = WS_POPUP;
|
||||||
} else {
|
} else {
|
||||||
exstyle = WS_EX_APPWINDOW;
|
exstyle = WS_EX_APPWINDOW;
|
||||||
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
||||||
|
|
|
@ -90,7 +90,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
str = (const wchar_t *)clipboard_data;
|
str = (const wchar_t *)clipboard_data;
|
||||||
ret = (*env)->NewString(env, str, wcslen(str));
|
ret = (*env)->NewString(env, str, (jsize)wcslen(str));
|
||||||
} else if (textAvailable) {
|
} else if (textAvailable) {
|
||||||
if (!OpenClipboard(NULL))
|
if (!OpenClipboard(NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -104,7 +104,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_WindowsSysImplementation_nGetClipboard
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = NewStringNativeWithLength(env, (const char *) clipboard_data, strlen(clipboard_data));
|
ret = NewStringNativeWithLength(env, (const char *) clipboard_data, (jsize)strlen(clipboard_data));
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
|
|
||||||
#define WINDOWCLASSNAME _T("LWJGL")
|
#define WINDOWCLASSNAME _T("LWJGL")
|
||||||
|
|
||||||
|
static jclass windowsDisplayClass;
|
||||||
|
static jmethodID javaWindowProc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* WindowProc for the GL window.
|
* WindowProc for the GL window.
|
||||||
*/
|
*/
|
||||||
|
@ -61,10 +64,12 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
jclass display_class;
|
jclass display_class;
|
||||||
jclass display_class_global;
|
jclass display_class_global;
|
||||||
jmethodID handleMessage_method;
|
jmethodID handleMessage_method;
|
||||||
LONG message_time;
|
LONG message_time;
|
||||||
|
*/
|
||||||
JNIEnv *env = getThreadEnv();
|
JNIEnv *env = getThreadEnv();
|
||||||
if (env != NULL && !(*env)->ExceptionOccurred(env)) {
|
if (env != NULL && !(*env)->ExceptionOccurred(env)) {
|
||||||
/*
|
/*
|
||||||
|
@ -80,6 +85,8 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
* a window is created, where we are sure that the calling class' classloader has
|
* a window is created, where we are sure that the calling class' classloader has
|
||||||
* LWJGL classes in it.
|
* LWJGL classes in it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||||
if (display_class_global == NULL) {
|
if (display_class_global == NULL) {
|
||||||
display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay");
|
display_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsDisplay");
|
||||||
|
@ -91,15 +98,27 @@ static LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
}
|
}
|
||||||
if (display_class_global != NULL) {
|
if (display_class_global != NULL) {
|
||||||
message_time = GetMessageTime();
|
message_time = GetMessageTime();
|
||||||
handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)I");
|
handleMessage_method = (*env)->GetStaticMethodID(env, display_class_global, "handleMessage", "(JIJJJ)J");
|
||||||
if (handleMessage_method != NULL)
|
if (handleMessage_method != NULL)
|
||||||
return (*env)->CallStaticIntMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
|
return (*env)->CallStaticLongMethod(env, display_class_global, handleMessage_method, (jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)message_time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (*env)->CallStaticLongMethod(
|
||||||
|
env, windowsDisplayClass, javaWindowProc,
|
||||||
|
(jlong)(intptr_t)hWnd, (jint)msg, (jlong)wParam, (jlong)lParam, (jlong)GetMessageTime()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_setWindowProc(JNIEnv *env, jclass clazz, jobject method) {
|
||||||
|
windowsDisplayClass = clazz;
|
||||||
|
javaWindowProc = (*env)->FromReflectedMethod(env, method);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_defWindowProc(JNIEnv *env, jclass unused, jlong hWnd, jint msg, jlong wParam, jlong lParam) {
|
||||||
return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
|
return DefWindowProc((HWND)(INT_PTR)hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +186,10 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nCreateWindow(JNIEn
|
||||||
return (INT_PTR)hwnd;
|
return (INT_PTR)hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetParent(JNIEnv *env, jclass clazz, jlong hwnd_ptr) {
|
||||||
|
return (INT_PTR)GetParent((HWND)(INT_PTR)hwnd_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReleaseDC(JNIEnv *env, jclass clazz, jlong hwnd_ptr, jlong hdc_ptr) {
|
||||||
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
|
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
|
||||||
HDC hdc = (HDC)(INT_PTR)hdc_ptr;
|
HDC hdc = (HDC)(INT_PTR)hdc_ptr;
|
||||||
|
@ -309,6 +332,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nGetVersion(JNIEn
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env, jclass unused, jlong hwnd_ptr, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean child) {
|
||||||
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
|
HWND hwnd = (HWND)(INT_PTR)hwnd_ptr;
|
||||||
|
/*
|
||||||
DWORD exstyle, windowflags;
|
DWORD exstyle, windowflags;
|
||||||
RECT clientSize;
|
RECT clientSize;
|
||||||
|
|
||||||
|
@ -329,11 +353,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_nReshape(JNIEnv *env
|
||||||
);
|
);
|
||||||
|
|
||||||
SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER);
|
SetWindowPos(hwnd, HWND_TOP, x, y, clientSize.right - clientSize.left, clientSize.bottom - clientSize.top, SWP_NOZORDER);
|
||||||
|
*/
|
||||||
|
SetWindowPos(hwnd, HWND_TOP, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) {
|
static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height) {
|
||||||
unsigned char col;
|
|
||||||
unsigned char mask;
|
|
||||||
BITMAPV5HEADER bitmapInfo;
|
BITMAPV5HEADER bitmapInfo;
|
||||||
HBITMAP cursorMask;
|
HBITMAP cursorMask;
|
||||||
HBITMAP colorBitmap;
|
HBITMAP colorBitmap;
|
||||||
|
@ -345,8 +369,6 @@ static HICON createWindowIcon(JNIEnv *env, jint *pixels, jint width, jint height
|
||||||
int imageSize;
|
int imageSize;
|
||||||
unsigned char *maskPixels;
|
unsigned char *maskPixels;
|
||||||
int widthInBytes;
|
int widthInBytes;
|
||||||
int leftShift;
|
|
||||||
int maskPixelsOff;
|
|
||||||
int scanlineWidth;
|
int scanlineWidth;
|
||||||
HBITMAP colorDIB;
|
HBITMAP colorDIB;
|
||||||
|
|
||||||
|
@ -475,7 +497,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getClientRect
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx
|
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_adjustWindowRectEx
|
||||||
(JNIEnv *env, jclass unused, jobject rect_buffer, jlong style, jboolean menu, jlong styleex) {
|
(JNIEnv *env, jclass unused, jobject rect_buffer, jint style, jboolean menu, jint styleex) {
|
||||||
jboolean result;
|
jboolean result;
|
||||||
RECT clientRect;
|
RECT clientRect;
|
||||||
copyBufferToRect(env, rect_buffer, &clientRect);
|
copyBufferToRect(env, rect_buffer, &clientRect);
|
||||||
|
|
|
@ -93,7 +93,7 @@ static jstring queryRegistrationKey(JNIEnv *env, HKEY root_key, LPCTSTR subkey,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result[buf_size - 1] = '\0';
|
result[buf_size - 1] = '\0';
|
||||||
java_result = NewStringNativeWithLength(env, result, strlen(result));
|
java_result = NewStringNativeWithLength(env, result, (jsize)strlen(result));
|
||||||
free(result);
|
free(result);
|
||||||
return java_result;
|
return java_result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue