@@ -134,23 +134,31 @@ private static ByteBuffer transformCursorImage(final IntBuffer imageData, final
134
134
private boolean cursorVisible ;
135
135
private boolean initialized ;
136
136
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
+
137
143
public GlfwMouseInput (final LwjglWindow context ) {
138
144
this .context = context ;
139
145
this .cursorVisible = true ;
140
146
}
141
147
142
148
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
+ }
151
159
152
- xDelta = x - mouseX ;
153
- yDelta = y - mouseY ;
160
+ int xDelta = x - mouseX ;
161
+ int yDelta = y - mouseY ;
154
162
mouseX = x ;
155
163
mouseY = y ;
156
164
@@ -249,12 +257,14 @@ private void initCurrentMousePosition(long window) {
249
257
double [] y = new double [1 ];
250
258
glfwGetCursorPos (window , x , y );
251
259
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
+ }
258
268
}
259
269
260
270
/**
0 commit comments