fix for invalid hotspot error when scalingFactor becomes small. Override repaint method to (hopefully) make updates immediate.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4687 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tigervnc/vncviewer/CConn.java b/java/src/com/tigervnc/vncviewer/CConn.java
index 61b0ca1..599c8b2 100644
--- a/java/src/com/tigervnc/vncviewer/CConn.java
+++ b/java/src/com/tigervnc/vncviewer/CConn.java
@@ -88,11 +88,9 @@
sp.getSize().height != cc.desktop.scaledHeight) {
cc.reconfigureViewport();
if (cc.desktop.cursor != null) {
- cc.setCursor(cc.desktop.cursor.width(),
- cc.desktop.cursor.height(),
- cc.desktop.cursor.hotspot,
- cc.desktop.cursor.data,
- cc.desktop.cursor.mask);
+ Cursor cursor = cc.desktop.cursor;
+ cc.setCursor(cursor.width(),cursor.height(),cursor.hotspot,
+ cursor.data, cursor.mask);
}
}
}
@@ -922,8 +920,6 @@
if (desktop != null) {
reconfigureViewport();
viewport.update(viewport.g);
- if (desktop.cursor != null)
- setCursor(desktop.cursor.width(), desktop.cursor.height(), desktop.cursor.hotspot, desktop.cursor.data, desktop.cursor.mask);
}
} else if(options.fixedRatioScale) {
viewer.scalingFactor.setParam("FixedRatio");
@@ -931,8 +927,6 @@
if (desktop != null) {
reconfigureViewport();
viewport.update(viewport.g);
- if (desktop.cursor != null)
- setCursor(desktop.cursor.width(), desktop.cursor.height(), desktop.cursor.hotspot, desktop.cursor.data, desktop.cursor.mask);
}
} else {
String scaleString =
@@ -944,8 +938,6 @@
if (oldScaleFactor != scaleFactor && desktop != null) {
reconfigureViewport();
viewport.update(viewport.g);
- if (desktop.cursor != null)
- setCursor(desktop.cursor.width(), desktop.cursor.height(), desktop.cursor.hotspot, desktop.cursor.data, desktop.cursor.mask);
}
}
diff --git a/java/src/com/tigervnc/vncviewer/DesktopWindow.java b/java/src/com/tigervnc/vncviewer/DesktopWindow.java
index 97a3355..027683c 100644
--- a/java/src/com/tigervnc/vncviewer/DesktopWindow.java
+++ b/java/src/com/tigervnc/vncviewer/DesktopWindow.java
@@ -157,10 +157,12 @@
int cw = (int)Math.floor((float)cursor.width() * scaleWidthRatio);
int ch = (int)Math.floor((float)cursor.height() * scaleHeightRatio);
int hint = java.awt.Image.SCALE_DEFAULT;
+ hotspot = new Point((int)Math.floor((float)hotspot.x * scaleWidthRatio),
+ (int)Math.floor((float)hotspot.y * scaleHeightRatio));
Image cursorImage = (cw <= 0 || ch <= 0) ? tk.createImage(bitmap) :
tk.createImage(bitmap).getScaledInstance(cw,ch,hint);
- softCursor = (tk.createCustomCursor(cursorImage,
- new java.awt.Point(hotspot.x,hotspot.y), "Cursor"));
+ softCursor = tk.createCustomCursor(cursorImage,
+ new java.awt.Point(hotspot.x,hotspot.y), "Cursor");
}
if (softCursor != null) {
@@ -313,10 +315,6 @@
return new Dimension(scaledWidth, scaledHeight);
}
- public void update(Graphics g) {
- //repaint();
- }
-
public void setScaledSize() {
if (!cc.options.autoScale && !cc.options.fixedRatioScale) {
scaledWidth = (int)Math.floor((float)cc.cp.width * (float)cc.scaleFactor/100.0);
@@ -358,6 +356,10 @@
}
}
+ public void repaint() {
+ if (graphics != null)
+ super.update(graphics);
+ }
String oldContents = "";