Skip to content

Commit

Permalink
A first attempt to solve #3180. Needs more thorough testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Sep 8, 2021
1 parent 4681192 commit 179c525
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -205,11 +205,16 @@ public int getFPS() {
public void dispatchKeyEvent(final char e) {
for (final IEventLayerListener gl : listeners) { gl.keyPressed(String.valueOf(e)); }
}

int autoScaleUp(int c) {
if (PlatformHelper.isWindows() && PlatformHelper.getDeviceZoom() > 100) return c;
return PlatformHelper.autoScaleUp(c);
}

@Override
public void setMousePosition(final int xm, final int ym) {
final int x = PlatformHelper.autoScaleUp(xm);
final int y = PlatformHelper.autoScaleUp(ym);
final int x = autoScaleUp(xm);
final int y = autoScaleUp(ym);
if (mousePosition == null) {
mousePosition = new Point(x, y);
} else {
Expand All @@ -220,11 +225,8 @@ public void setMousePosition(final int xm, final int ym) {
@Override
public void draggedTo(final int x, final int y) {
final Point origin = getOrigin();
setOrigin(origin.x + PlatformHelper.autoScaleUp(x) - getMousePosition().x,
origin.y + PlatformHelper.autoScaleUp(y) - getMousePosition().y);
// DEBUG.OUT("Translation on X : " + (PlatformHelper.autoScaleUp(x) - getMousePosition().x) + " | on Y : "
// + (PlatformHelper.autoScaleUp(y) - getMousePosition().y));
// DEBUG.OUT("Old Origin = " + origin + " | New Origin = " + getOrigin());
setOrigin(origin.x + autoScaleUp(x) - getMousePosition().x,
origin.y + autoScaleUp(y) - getMousePosition().y);
setMousePosition(x, y);
updateDisplay(true);
}
Expand Down

0 comments on commit 179c525

Please sign in to comment.