Skip to content

Commit 61693e0

Browse files
committed
fixed wrong mouse coordinates on Windows customers with screen scaling > 100%
this fixes #18 (cherry picked from commit faa45f7)
1 parent 783b695 commit 61693e0

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Changelog for Remote Support Tool
44
1.0.1 (13 Mar 2019)
55
-------------------
66

7-
...
7+
- fixed [issue #18](https://github.com/OpenIndex/RemoteSupportTool/issues/18): Mouse is shifted on Windows clients with high resolution screen
88

99

1010
1.0.0 (20 Oct 2018)

Customer/src/main/java/de/openindex/support/customer/CustomerApplication.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.awt.event.ActionEvent;
3939
import java.awt.event.ActionListener;
4040
import java.awt.event.KeyEvent;
41+
import java.awt.geom.AffineTransform;
4142
import java.awt.image.BufferedImage;
4243
import java.io.ByteArrayOutputStream;
4344
import java.io.File;
@@ -444,7 +445,27 @@ else if (request.keyChar != KeyEvent.CHAR_UNDEFINED) {
444445
} else if (object instanceof MouseMoveRequest) {
445446

446447
final MouseMoveRequest request = (MouseMoveRequest) object;
447-
robot.mouseMove(request.x, request.y);
448+
final int x;
449+
final int y;
450+
451+
// On Windows systems we need to convert the coordinates
452+
// according to the current screen scaling factor.
453+
if (SystemUtils.IS_OS_WINDOWS) {
454+
final GraphicsConfiguration screenConfiguration = screen.getDefaultConfiguration();
455+
final AffineTransform transform = screenConfiguration.getDefaultTransform();
456+
final double scaleX = (transform != null && transform.getScaleX() > 0) ?
457+
transform.getScaleX() : 1;
458+
final double scaleY = (transform != null && transform.getScaleY() > 0) ?
459+
transform.getScaleY() : 1;
460+
461+
x = (int) ((double) request.x / scaleX);
462+
y = (int) ((double) request.y / scaleY);
463+
} else {
464+
x = request.x;
465+
y = request.y;
466+
}
467+
468+
robot.mouseMove(x, y);
448469

449470
} else if (object instanceof MousePressRequest) {
450471

0 commit comments

Comments
 (0)