aboutsummaryrefslogtreecommitdiffstats
path: root/java/com/tigervnc/vncviewer
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/tigervnc/vncviewer')
-rw-r--r--java/com/tigervnc/vncviewer/Viewport.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/java/com/tigervnc/vncviewer/Viewport.java b/java/com/tigervnc/vncviewer/Viewport.java
index c293cb7d..f7ec9f51 100644
--- a/java/com/tigervnc/vncviewer/Viewport.java
+++ b/java/com/tigervnc/vncviewer/Viewport.java
@@ -200,8 +200,8 @@ class Viewport extends JPanel implements ActionListener {
Graphics2D g2 = tmp.createGraphics();
g2.drawImage(cursor, 0, 0, cw, ch, 0, 0, width, height, null);
g2.dispose();
- x = (int) Math.min(Math.floor((float) x * (float) cw / (float) width), cw - 1);
- y = (int) Math.min(Math.floor((float) y * (float) ch / (float) height), ch - 1);
+ x = (int) Math.min(Math.floor((float) x * (float) cw / (float) width), Math.max(cw - 1, 0));
+ y = (int) Math.min(Math.floor((float) y * (float) ch / (float) height), Math.max(ch - 1, 0));
cursor = tmp;
}