From: Brian Hinz Date: Sun, 2 Oct 2011 00:44:41 +0000 (+0000) Subject: fix for invalid hotspot error when scalingFactor becomes small. Override repaint... X-Git-Tag: v1.1.90~123 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=93338f609c0eed15e5cff7eb3a2de5e1d451f80f;p=tigervnc.git 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 61b0ca18..599c8b2d 100644 --- a/java/src/com/tigervnc/vncviewer/CConn.java +++ b/java/src/com/tigervnc/vncviewer/CConn.java @@ -88,11 +88,9 @@ class ViewportFrame extends JFrame implements ComponentListener 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 @@ public class CConn extends CConnection 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 @@ public class CConn extends CConnection 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 @@ public class CConn extends CConnection 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 97a3355c..027683c3 100644 --- a/java/src/com/tigervnc/vncviewer/DesktopWindow.java +++ b/java/src/com/tigervnc/vncviewer/DesktopWindow.java @@ -157,10 +157,12 @@ class DesktopWindow extends JPanel implements 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 @@ class DesktopWindow extends JPanel implements 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 @@ class DesktopWindow extends JPanel implements } } + public void repaint() { + if (graphics != null) + super.update(graphics); + } String oldContents = "";