From bf273a9424fe7d61982317bc80b2155486a9dc5f Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Sun, 16 Apr 2023 14:29:25 +0300 Subject: [PATCH] Fix HiDPI support on non-touch devices --- client/webgl_listeners.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/webgl_listeners.js b/client/webgl_listeners.js index cbfac86..7e78fbb 100644 --- a/client/webgl_listeners.js +++ b/client/webgl_listeners.js @@ -50,7 +50,7 @@ function mousedown(e, state, context) { return; } - const screenp = {'x': e.clientX, 'y': e.clientY}; + const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; const canvasp = screen_to_canvas(state, screenp); clear_dynamic_stroke(state, context, state.me); @@ -71,7 +71,7 @@ function mousemove(e, state, context) { do_draw = true; } - const screenp = {'x': e.clientX, 'y': e.clientY}; + const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; const canvasp = screen_to_canvas(state, screenp); state.cursor = screenp; @@ -121,7 +121,7 @@ function mouseup(e, state, context) { } function wheel(e, state, context) { - const screenp = {'x': e.clientX, 'y': e.clientY}; + const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; const canvasp = screen_to_canvas(state, screenp); const dz = (e.deltaY < 0 ? 0.1 : -0.1);