Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-268521

Minecraft window doesn't have a minimal width and height

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.20.4, 24w06a, 24w07a, 24w09a, 24w13a, 1.20.5 Pre-Release 1, 1.20.5 Pre-Release 2, 1.20.5, 24w18a, 24w21b, 1.21, 24w33a
    • None
    • OS: Ubuntu 22.04 LTS
    • Confirmed
    • UI
    • Normal
    • Platform

      Despite the laucnher having a minimal limit on how small the game window can be at start being 300x260 px, Minecraft itself can be resized to any size you want, causing bugs like MC-268490

      Steps to reproduce:

      1. Open the Minecraft launcher, click on installations tab and click on any installation.
      2. In the opened window set the window size to 0x0. "Minimal resolution is 300x260." message appears.
      3. Open minecraft and try to resize minecraft to be as small as possible. Minecraft window can be smaller than 300x260

      Observed result:

      Minecraft window doesn't have a minimal width and height and can be smaller than 300x260 

      Expected result:

      Minecraft window should have a minimal width and height being set to 300x260

      Fix:

      The following code is based on a decompiled version of 1.20.5 Pre-Release 1 using official mappings.

      com.mojang.blaze3d.platform.Window.java
      public final class Window implements AutoCloseable {
          ...
          public Window(WindowEventHandler $$0, ScreenManager $$1, DisplayData $$2, @Nullable String $$3, String $$4) {
              ...
              GLFW.glfwMakeContextCurrent(this.window);
              GL.createCapabilities();
              this.setMode();
              this.refreshFramebufferSize();
              GLFW.glfwSetFramebufferSizeCallback(this.window, this::onFramebufferResize);
              GLFW.glfwSetWindowPosCallback(this.window, this::onMove);
              GLFW.glfwSetWindowSizeCallback(this.window, this::onResize);
              GLFW.glfwSetWindowFocusCallback(this.window, this::onFocus);
              GLFW.glfwSetCursorEnterCallback(this.window, this::onEnter);
          }
          ...
      } 

      As we can see, when the window is created, there is no restriction set to window size, this can be simply fixed by adding the following code at the end of Window function.

      GLFW.glfwSetWindowSizeLimits(this.window, 300, 260, GLFW.GLFW_DONT_CARE, GLFW.GLFW_DONT_CARE); // Based of GLFW window guide https://www.glfw.org/docs/3.3/window_guide.html#window_sizelimits

            Unassigned Unassigned
            kelianor kelianor
            Votes:
            3 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              CHK: