Fixed client drifting when rappidly toggling the GLWindow

This commit is contained in:
Sollace 2018-10-20 12:39:34 +02:00
parent 6feb20a331
commit 8d0c0a629e

View file

@ -91,6 +91,9 @@ public class GLWindow extends DropTarget {
return frame; return frame;
} }
private int frameFactorX;
private int frameFactorY;
private synchronized void open() throws LWJGLException { private synchronized void open() throws LWJGLException {
// Dimensions from LWJGL may have a non 1:1 scale on high DPI monitors. // Dimensions from LWJGL may have a non 1:1 scale on high DPI monitors.
int x = getScaledPixelUnit(Display.getX()); int x = getScaledPixelUnit(Display.getX());
@ -128,8 +131,8 @@ public class GLWindow extends DropTarget {
public void windowOpened(WindowEvent e) { public void windowOpened(WindowEvent e) {
// Once the window has opened compare the content and window dimensions to get // Once the window has opened compare the content and window dimensions to get
// the OS's frame size then reassign adjusted dimensions to match LWJGL's window. // the OS's frame size then reassign adjusted dimensions to match LWJGL's window.
int frameFactorX = frame.getWidth() - frame.getContentPane().getWidth(); frameFactorX = frame.getWidth() - frame.getContentPane().getWidth();
int frameFactorY = frame.getHeight() - frame.getContentPane().getHeight(); frameFactorY = frame.getHeight() - frame.getContentPane().getHeight();
frame.setSize(w + frameFactorX, h + frameFactorY); frame.setSize(w + frameFactorX, h + frameFactorY);
} }
@ -176,7 +179,7 @@ public class GLWindow extends DropTarget {
Display.setDisplayMode(Display.getDesktopDisplayMode()); Display.setDisplayMode(Display.getDesktopDisplayMode());
} else { } else {
Display.setDisplayMode(new DisplayMode(frame.getContentPane().getWidth(), frame.getContentPane().getHeight())); Display.setDisplayMode(new DisplayMode(frame.getContentPane().getWidth(), frame.getContentPane().getHeight()));
Display.setLocation(Math.max(0, frame.getX()), Math.max(0, frame.getY())); Display.setLocation(Math.max(0, frame.getX() + frameFactorX/3), Math.max(0, frame.getY() + frameFactorX/3));
} }
// https://bugs.mojang.com/browse/MC-68754 // https://bugs.mojang.com/browse/MC-68754