@@ -134,23 +134,31 @@ private static ByteBuffer transformCursorImage(final IntBuffer imageData, final
134134 private boolean cursorVisible ;
135135 private boolean initialized ;
136136
137+ /**
138+ * temporary storage for GLFW queries
139+ */
140+ private final float [] xScale = new float [1 ];
141+ private final float [] yScale = new float [1 ];
142+
137143 public GlfwMouseInput (final LwjglWindow context ) {
138144 this .context = context ;
139145 this .cursorVisible = true ;
140146 }
141147
142148 private void onCursorPos (final long window , final double xpos , final double ypos ) {
143- float [] xScale = new float [1 ];
144- float [] yScale = new float [1 ];
145- glfwGetWindowContentScale (window , xScale , yScale );
146-
147- int xDelta ;
148- int yDelta ;
149- int x = (int ) Math .round (xpos * xScale [0 ]);
150- int y = (int ) Math .round ((currentHeight - ypos ) * yScale [0 ]);
149+ int x ;
150+ int y ;
151+ if (context .isScaledContent ()) {
152+ glfwGetWindowContentScale (window , xScale , yScale );
153+ x = (int ) Math .round (xpos * xScale [0 ]);
154+ y = (int ) Math .round ((currentHeight - ypos ) * yScale [0 ]);
155+ } else {
156+ x = (int ) Math .round (xpos );
157+ y = (int ) Math .round (currentHeight - ypos );
158+ }
151159
152- xDelta = x - mouseX ;
153- yDelta = y - mouseY ;
160+ int xDelta = x - mouseX ;
161+ int yDelta = y - mouseY ;
154162 mouseX = x ;
155163 mouseY = y ;
156164
@@ -249,12 +257,14 @@ private void initCurrentMousePosition(long window) {
249257 double [] y = new double [1 ];
250258 glfwGetCursorPos (window , x , y );
251259
252- float [] xScale = new float [1 ];
253- float [] yScale = new float [1 ];
254- glfwGetWindowContentScale (window , xScale , yScale );
255-
256- mouseX = (int ) Math .round (x [0 ] * xScale [0 ]);
257- mouseY = (int ) Math .round ((currentHeight - y [0 ]) * yScale [0 ]);
260+ if (context .isScaledContent ()) {
261+ glfwGetWindowContentScale (window , xScale , yScale );
262+ mouseX = (int ) Math .round (x [0 ] * xScale [0 ]);
263+ mouseY = (int ) Math .round ((currentHeight - y [0 ]) * yScale [0 ]);
264+ } else {
265+ mouseX = (int ) Math .round (x [0 ]);
266+ mouseY = (int ) Math .round (currentHeight - y [0 ]);
267+ }
258268 }
259269
260270 /**
0 commit comments