Skip to content

Commit 00eefb5

Browse files
improve window pos clamping and add comments
1 parent a20d099 commit 00eefb5

File tree

1 file changed

+3
-2
lines changed
  • enigma-swing/src/main/java/org/quiltmc/enigma/gui

1 file changed

+3
-2
lines changed

enigma-swing/src/main/java/org/quiltmc/enigma/gui/Gui.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
import java.util.stream.Stream;
8080

8181
public class Gui {
82-
private static final int DEFAULT_MIN_LEFT_ON_SCREEN = 300;
8382
private static final int DEFAULT_MIN_TOP_ON_SCREEN = 200;
8483

8584
private final MainWindow mainWindow;
@@ -238,7 +237,9 @@ private void setupUi() {
238237
final Point windowPos = Config.main().windowPos.value().toPoint();
239238
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
240239

241-
final int clampedX = Utils.clamp(windowPos.x, 0, screenSize.width - ScaleUtil.scale(DEFAULT_MIN_LEFT_ON_SCREEN));
240+
// keep the whole width (or as much as will fit) on-screen so window controls in the title bar are accessible
241+
final int clampedX = Utils.clamp(windowPos.x, 0, Math.max(0, screenSize.width - frame.getSize().width));
242+
// allow some of the bottom to be off-screen, but not the top, because of the title bar
242243
final int clampedY = Utils.clamp(windowPos.y, 0, screenSize.height - ScaleUtil.scale(DEFAULT_MIN_TOP_ON_SCREEN));
243244

244245
if (windowPos.x != clampedX || windowPos.y != clampedY) {

0 commit comments

Comments
 (0)