summaryrefslogtreecommitdiff
path: root/src/skel
diff options
context:
space:
mode:
authorGreg V <greg@unrelenting.technology>2020-09-28 04:52:13 +0300
committerGreg V <greg@unrelenting.technology>2020-09-28 04:52:13 +0300
commitb95accb8ff6a594d1a920b94823b38be3515f149 (patch)
tree461337bf26c699da02ad64b9050e745288e5ca6d /src/skel
parent5654347c5d511c53146fe4ce1710938b311d986e (diff)
glfw: scale cursor position by the ratio of framebuffer to screen size
This fixes the mouse being constrained to the top left quarter of the window on Wayland HiDPI setups.
Diffstat (limited to 'src/skel')
-rw-r--r--src/skel/glfw/glfw.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp
index f1b9c695..d7054b9c 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -1397,8 +1397,11 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) {
// TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000
void
cursorCB(GLFWwindow* window, double xpos, double ypos) {
- FrontEndMenuManager.m_nMouseTempPosX = xpos;
- FrontEndMenuManager.m_nMouseTempPosY = ypos;
+ int bufw, bufh, winw, winh;
+ glfwGetWindowSize(window, &winw, &winh);
+ glfwGetFramebufferSize(window, &bufw, &bufh);
+ FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw);
+ FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh);
}
void