From 7e788041578f285ff3eb822fbe13ecca41336734 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 20 Oct 2018 12:21:53 +0200 Subject: [PATCH] fixed rapidly toggling the GLWindow causes the client to slide up and off the screen --- .../java/com/voxelmodpack/hdskins/upload/GLWindow.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/GLWindow.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/GLWindow.java index e903dffb..59d7b1bb 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/GLWindow.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/GLWindow.java @@ -66,7 +66,7 @@ public class GLWindow extends DropTarget { } private static int getScaledPixelUnit(int i) { - return (int)Math.floor(i * Display.getPixelScaleFactor()); + return Math.max((int)Math.floor(i * Display.getPixelScaleFactor()), 0); } private final Minecraft mc = Minecraft.getMinecraft(); @@ -128,10 +128,10 @@ public class GLWindow extends DropTarget { public void windowOpened(WindowEvent e) { // 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. - float frameFactorX = frame.getWidth() - frame.getContentPane().getWidth(); - float frameFactorY = frame.getHeight() - frame.getContentPane().getHeight(); + int frameFactorX = frame.getWidth() - frame.getContentPane().getWidth(); + int frameFactorY = frame.getHeight() - frame.getContentPane().getHeight(); - frame.setSize((int)Math.floor(w + frameFactorX), (int)Math.floor(h + frameFactorY)); + frame.setSize(w + frameFactorX, h + frameFactorY); } }); frame.addComponentListener(new ComponentAdapter() { @@ -176,7 +176,7 @@ public class GLWindow extends DropTarget { Display.setDisplayMode(Display.getDesktopDisplayMode()); } else { Display.setDisplayMode(new DisplayMode(frame.getContentPane().getWidth(), frame.getContentPane().getHeight())); - Display.setLocation(frame.getX(), frame.getY()); + Display.setLocation(Math.max(0, frame.getX()), Math.max(0, frame.getY())); } // https://bugs.mojang.com/browse/MC-68754