The mouse coordinates are clipped to the original window size on the windows nightly from 11.8. (not checked with other platforms).
The following test case shows that DisplayImplementation.getWidth() doesn't change while resizing using Canvas:
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicReference;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
/**
*
* @author Matthias Mann
*/
public class Test {
private static boolean closeRequested = false;
final static AtomicReference<Dimension> newCanvasSize = new AtomicReference<Dimension>();
public static void main(String[] args)
{
Frame frame = new Frame("Test");
frame.setLayout(new BorderLayout());
final Canvas canvas = new Canvas();
canvas.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e)
{
newCanvasSize.set(canvas.getSize());
}
});
frame.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowGainedFocus(WindowEvent e)
{
canvas.requestFocusInWindow();
}
});
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e)
{
closeRequested = true;
}
});
frame.add(canvas, BorderLayout.CENTER);
try {
Display.setParent(canvas);
Display.setVSyncEnabled(true);
frame.setPreferredSize(new Dimension(1024, 786));
frame.setMinimumSize(new Dimension(800, 600));
frame.pack();
frame.setVisible(true);
Display.create();
Dimension newDim;
Field f = Display.class.getDeclaredField("display_impl");
f.setAccessible(true);
Object di = f.get(null);
Method m = di.getClass().getMethod("getWidth");
m.setAccessible(true);
while(!Display.isCloseRequested() && !closeRequested)
{
newDim = newCanvasSize.getAndSet(null);
if (newDim != null)
{
GL11.glViewport(0, 0, newDim.width, newDim.height);
System.out.println(newDim.width + " " + m.invoke(di));
}
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
Display.update();
}
Display.destroy();
frame.dispose();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Ok more information as to why this is a critical regression:
By default the the mouse movement is clipped to the Display size. With this bug the size values used by Mouse are not updated when resizing using Display.setParent().
This causes the mouse movement to be clipped to the original display size.
A work around is to disable clipping of mouse coordinates using
Mouse.setClipMouseCoordinatesToWindow(false); // new in LWJGL 2.8
or using:
-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true
So most apps written against 2.7.x using the Canvas based resizing will break.
this should be fixed in svn now.
thx for finding and reporting.