From f0aa04a7ee32ff36d04cfa5a92f4f887cf37f1d1 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:07:42 -0500 Subject: [PATCH] fix: compute logical mouse position using window scale factor Fixes mouse support in menus on systems with scaling factors other than 1.0x --- Minecraft.Client/UI/Screen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Minecraft.Client/UI/Screen.cpp b/Minecraft.Client/UI/Screen.cpp index ff6bee12d..1bac8ed36 100644 --- a/Minecraft.Client/UI/Screen.cpp +++ b/Minecraft.Client/UI/Screen.cpp @@ -54,7 +54,7 @@ void Screen::mouseClicked(int x, int y, int buttonNum) { if (buttonNum == 0) { - AUTO_VAR(itEnd, buttons.end()); + AUTO_VAR(itEnd, buttons.end()); for (AUTO_VAR(it, buttons.begin()); it != itEnd; it++) { Button *button = *it; //buttons[i]; @@ -116,11 +116,15 @@ void Screen::updateEvents() GLFWwindow* window = glfwGetCurrentContext(); if (!window) return; + float windowScaleX = 1; + float windowScaleY = 1; + glfwGetWindowContentScale(window, &windowScaleX, &windowScaleY); + double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); - int xMouse = (int)xpos * screenWidth / fbw; - int yMouse = (int)ypos * screenHeight / fbh - 1; + int xMouse = (int)(xpos * windowScaleX) * screenWidth / fbw; + int yMouse = (int)(ypos * windowScaleY) * screenHeight / fbh - 1; static bool prevLeftState = false; static bool prevRightState = false;