summaryrefslogtreecommitdiff
path: root/src/skel/glfw
diff options
context:
space:
mode:
authorGreg V <greg@unrelenting.technology>2020-09-28 04:52:13 +0300
committererorcun <erorcunerorcun@hotmail.com.tr>2020-11-18 17:10:49 +0300
commit7c1497a058cdf877a2e9fbc3ae607ad1cf733c61 (patch)
tree1242de8dadd500930d2a291f5e11bf031e003247 /src/skel/glfw
parentd05c50ea743f42bc9c426b7b6c2f9598b8bc7f94 (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/glfw')
-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 73d6fb05..8d1b7d90 100644
--- a/src/skel/glfw/glfw.cpp
+++ b/src/skel/glfw/glfw.cpp
@@ -1438,8 +1438,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